mirror of
https://github.com/obgm/libcoap.git
synced 2026-10-26 20:51:38 +03:00
added string representation of encoded value to payload of sent pdu
This commit is contained in:
1 parent
f98eeb45cb
commit
feabb53c6c
1 file changed
+7
@@ -20,6 +20,8 @@ coap_pdu_t *
|
||||
make_pdu( unsigned int value ) {
|
||||
coap_pdu_t *pdu;
|
||||
unsigned char enc;
|
||||
static char buf[20];
|
||||
int len;
|
||||
|
||||
if ( ! ( pdu = coap_new_pdu() ) )
|
||||
return NULL;
|
||||
@@ -30,6 +32,11 @@ make_pdu( unsigned int value ) {
|
||||
enc = COAP_PSEUDOFP_ENCODE(value);
|
||||
coap_add_data( pdu, 1, &enc);
|
||||
|
||||
len = snprintf(buf, 20, "%u", COAP_PSEUDOFP_DECODE(enc));
|
||||
if ( len > 0 ) {
|
||||
coap_add_data( pdu, len, buf );
|
||||
}
|
||||
|
||||
return pdu;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user