added string representation of encoded value to payload of sent pdu

This commit is contained in:
Olaf Bergmann committed 2010-07-06 13:43:02 +02:00
1 parent f98eeb45cb
commit feabb53c6c
1 file changed
+7
+7
View File
@@ -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;
}