mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-20 22:39:05 +03:00
coap-client: Always define a token when doing a subscribe
Some servers insist there being a token when a subscription Observe is initiated.
This commit is contained in:
1 parent
0583a6734a
commit
2b1ec9f270
2 files changed
+10
-2
No files matched your search
@@ -637,7 +637,8 @@ usage(const char *program, const char *version) {
|
||||
"\t \t\ttls_engine_conf_file contains TLS ENGINE configuration.\n"
|
||||
"\t \t\tSee coap-tls-engine-conf(5) for definitions.\n"
|
||||
"\t-s duration\tSubscribe to / Observe resource for given duration\n"
|
||||
"\t \t\tin seconds\n"
|
||||
"\t \t\tin seconds. If '-T token' is not used, then the initial\n"
|
||||
"\t \t\ttoken is defined as non empty\n"
|
||||
"\t-t type\t\tContent format for given resource for PUT/POST\n"
|
||||
"\t-v num \t\tVerbosity level (default 4, maximum is 8) for general\n"
|
||||
"\t \t\tCoAP logging\n"
|
||||
@@ -2324,6 +2325,12 @@ main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
|
||||
if (doing_observe && the_token.length == 0) {
|
||||
/* Some servers insist on a token when doing observe */
|
||||
the_token.length = 1;
|
||||
the_token.s[0] = 0x01; /* a token */
|
||||
}
|
||||
|
||||
session = get_session(ctx,
|
||||
node_str[0] ? node_str : NULL,
|
||||
port_str[0] ? port_str : NULL,
|
||||
|
||||
@@ -119,7 +119,8 @@ OPTIONS - General
|
||||
|
||||
*-s* duration::
|
||||
Subscribe to / observe the resource specified by URI for the given
|
||||
'duration' in seconds.
|
||||
'duration' in seconds. If *-T token* is not used, then the initial token is
|
||||
defined as non empty.
|
||||
|
||||
*-t* type::
|
||||
Content format for given resource for PUT/POST. 'type' must be either
|
||||
|
||||
Reference in new issue
Block a user