1# OpenThread CLI - SRP Client
2
3## Command List
4
5Usage : `srp client [command] ...`
6
7- [help](#help)
8- [autostart](#autostart)
9- [callback](#callback)
10- [host](#host)
11- [keyleaseinterval](#keyleaseinterval)
12- [leaseinterval](#leaseinterval)
13- [server](#server)
14- [service](#service)
15- [start](#start)
16- [state](#state)
17- [stop](#stop)
18- [ttl](#ttl)
19
20## Command Details
21
22### help
23
24Usage: `srp client help`
25
26Print SRP client help menu.
27
28```bash
29> srp client help
30autostart
31callback
32help
33host
34keyleaseinterval
35leaseinterval
36service
37start
38state
39stop
40ttl
41Done
42```
43
44### autostart
45
46Usage `srp client autostart [enable|disable]`
47
48Enable/Disable auto start mode in SRP client. This command requires `OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE` feature to be enabled.
49
50Get the current autostart mode.
51
52```bash
53> srp client autostart
54Disabled
55Done
56```
57
58Set the autostart mode.
59
60```bash
61> srp client autostart enable
62Done
63
64> srp client autostart
65Enabled
66Done
67```
68
69### callback
70
71Usage `srp client callback [enable|disable]`
72
73Enable/Disable printing callback events from SRP client.
74
75Get current callback mode
76
77```bash
78> srp client callback
79Disabled
80Done
81```
82
83Set callback mode
84
85```bash
86> srp client callback enable
87Done
88
89> srp client callback
90Enabled
91Done
92```
93
94#### Example
95
96When two services are successfully registered:
97
98```bash
99SRP client callback - error:OK
100Host info:
101    name:"dev4312", state:Registered, addrs:[fd00:0:0:0:0:0:0:1]
102Service list:
103    instance:"ins2", name:"_test2._udp", state:Registered, port:111, priority:1, weight:1
104    instance:"ins1", name:"_test1._udp,_sub1,_sub2", state:Registered, port:777, priority:0, weight:0
105```
106
107When service `ins2` is removed:
108
109```bash
110SRP client callback - error:OK
111Host info:
112    name:"dev4312", state:Registered, addrs:[fd00:0:0:0:0:0:0:1]
113Service list:
114    instance:"ins1", name:"_test1._udp", state:Registered, port:777, priority:0, weight:0
115Removed service list:
116    instance:"ins2", name:"_test2._udp,_sub1,_sub2", state:Removed, port:111, priority:1, weight:1
117```
118
119When host info (and all services) is removed:
120
121```bash
122SRP client callback - error:OK
123Host info:
124    name:"dev4312", state:Removed, addrs:[fd00:0:0:0:0:0:0:1]
125Service list:
126Removed service list:
127    instance:"ins1", name:"_test1._udp", state:Removed, port:777, priority:0, weight:0
128```
129
130### host
131
132Usage: `srp client host`
133
134Print the full host info (host name, state, list of host addresses).
135
136```bash
137> srp client host
138name:"dev4312", state:Registered, addrs:[fd00:0:0:0:0:0:0:1234, fd00:0:0:0:0:0:0:beef]
139Done
140```
141
142When auto host address mode is enabled.
143
144```bash
145srp client host
146name:"dev1234", state:Registered, addrs:auto
147Done
148```
149
150### host name
151
152Usage: `srp client host name [name]`
153
154Get the host name.
155
156```bash
157> srp client host name
158dev4312
159Done
160```
161
162Set host name (can be set when the host is removed or not yet registered with server).
163
164```bash
165srp client host name dev4312
166Done
167```
168
169### host address
170
171Usage : `srp client host address [auto | <address> ...]`
172
173Indicate auto address mode is enabled.
174
175```bash
176> srp client host address
177auto
178Done
179```
180
181Get the list of host addresses (when auto host address is not enabled).
182
183```bash
184> srp client host address
185fd00:0:0:0:0:0:0:1234
186fd00:0:0:0:0:0:0:beef
187Done
188```
189
190Enable auto host address mode. When enabled client will automatically use all preferred Thread netif unicast addresses excluding all link-local and mesh-local addresses. If there is no preferred address, then Mesh Local EID address is added. SRP client will automatically re-register if/when addresses on Thread netif get changed (e.g., new address is added or existing address is removed or marked as non-preferred).
191
192```bash
193> srp client host address auto
194Done
195```
196
197Explicitly set the list of host addresses (can be set while client is running to update the host addresses), also disabled auto host address mode.
198
199```bash
200> srp client host address fd00::cafe
201Done
202```
203
204### host state
205
206Usage: `srp client host state`
207
208Get the host state.
209
210```bash
211> srp client host state
212Registered
213Done
214```
215
216The possible states are (same value for service state):
217
218- `ToAdd`: item to be added/registered.
219- `Adding`: item is being added/registered.
220- `ToRefresh`: item to be refreshed (renew lease).
221- `Refreshing`: item is being refreshed.
222- `ToRemove`: item to be removed.
223- `Removing`: item is being removed.
224- `Registered`: item is registered with server.
225- `Removed`: item is removed.
226
227### host remove
228
229Usage: `srp client host remove [removekeylease] [sendunregtoserver]`
230
231Remove host info and all services from server.
232
233- `removekeylease` is an optional boolean value indicating whether or not the host key lease should also be removed (default is false).
234- `sendunregtoserver` is a another optional boolean value indicating whether or not to send an update message to the server when host info is not yet registered (default is false).
235
236```bash
237> srp client host remove 1
238Done
239```
240
241### host clear
242
243Usage: `srp client host clear`
244
245Clear host info and all services on client (unlike `host remove`, with `host clear` no update is sent to server).
246
247```bash
248> srp client host clear
249Done
250```
251
252### keyleaseinterval
253
254Usage: `srp client keyleaseinterval [interval]`
255
256Get the key lease interval (in seconds).
257
258```bash
259> srp client keyleaseinterval
2601209600
261Done
262>
263```
264
265Set the key lease interval.
266
267```bash
268> srp client keyleaseinterval 864000
269Done
270```
271
272### leaseinterval
273
274Usage: `srp client leaseinterval [interval]`
275
276Get the lease interval (in seconds).
277
278```bash
279> srp client leaseinterval
2807200
281Done
282>
283```
284
285Set the lease interval.
286
287```bash
288> srp client leaseinterval 3600
289Done
290```
291
292### server
293
294Usage: `srp client server`
295
296Print the server socket address (IPv6 address and port number).
297
298```bash
299> srp client server
300[fd00:0:0:0:d88a:618b:384d:e760]:4724
301Done
302```
303
304### server address
305
306Print the server IPv6 address.
307
308```bash
309> srp client server address
310fd00:0:0:0:d88a:618b:384d:e760
311Done
312```
313
314### server port
315
316Print the server port number
317
318```bash
319> srp client server port
3204724
321Done
322```
323
324### service
325
326Usage: `srp client service`
327
328Print the list of services.
329
330```bash
331> srp client service
332instance:"ins2", name:"_test2._udp,_sub1,_sub2", state:Registered, port:111, priority:1, weight:1
333instance:"ins1", name:"_test1._udp", state:Registered, port:777, priority:0, weight:0
334Done
335```
336
337### service add
338
339Usage: `srp client service add <instancename> <servicename> <port> [priority] [weight] [txt]`
340
341Add a service with a given instance name, service name, port number, priority, weight and txt values.
342
343The `<servicename>` can optionally include a list of service subtype labels separated by comma.
344
345The priority and weight are optional and if not provided zero will be used. The txt should follow hex-string format and is treated as an already encoded TXT data byte sequence. It is also optional and if not provided it is considered empty.
346
347```bash
348> srp client service add ins1 _test1._udp 777
349Done
350
351> srp client service add ins2 _test2._udp,_sub1,_sub2 111 1 1
352Done
353```
354
355### service remove
356
357Usage: `srp client service remove <instancename> <servicename>`
358
359Remove a service with a give instance name and service name.
360
361```bash
362> srp client service remove ins2 _test2._udp
363Done
364```
365
366### service clear
367
368Usage: `srp client service clear <instancename> <servicename>`
369
370Clear a service with a give instance name and service name (unlike `service remove`, with `service clear` no update is sent to server and the entry is immediately removed from client list).
371
372```bash
373> srp client service clear ins2 _test2._udp
374Done
375```
376
377### service key
378
379Usage `srp client service key [enable|disable]`
380
381Enable/Disable "service key record inclusion" mode in SRP client. This command requires `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` feature to be enabled.
382
383KEY record is optional in Service Description Instruction (it is required and always included in the Host Description Instruction). The default behavior of SRP client is to not include it. This command is intended to override the default behavior for testing only (in a `REFERENCE_DEVICE` build).
384
385Get the current "service key record inclusion" mode.
386
387```bash
388> srp client service key
389Disabled
390Done
391```
392
393Set the "service key record inclusion" mode.
394
395```bash
396> srp client service key enable
397Done
398
399> srp client service key
400Enabled
401Done
402```
403
404### start
405
406Usage: `srp client start <serveraddr> <serverport>`
407
408Start the SRP client with a given server IPv6 address and port number.
409
410```bash
411> srp client start fd00::d88a:618b:384d:e760 4724
412Done
413```
414
415### state
416
417Usage: `srp client state`
418
419Indicates the state of SRP client, i.e., whether it is enabled or disabled.
420
421```bash
422> srp client state
423Enabled
424Done
425```
426
427### stop
428
429Usage: `srp client stop`
430
431Stop the SRP client.
432
433```bash
434> srp client stop
435Done
436```
437
438### ttl
439
440Usage: `srp client ttl [value]`
441
442Get the TTL (in seconds).
443
444```bash
445> srp client ttl
4467200
447Done
448>
449```
450
451Set the TTL.
452
453```bash
454> srp client ttl 3600
455Done
456```
457