coap_pdu_t: Obfuscate coap_pdu_t for applications

Move coap_pdu_t to coap_pdu_internal.h.

Move internal PDU based function definitions to coap_pdu_internal.h.

Replace most references to "struct coap_pdu_t" with "coap_pdu_t".

Create new enum coap_pdu_type_t, enum coap_pdu_code_t and coap_option_num_t,
using them where appropriate for clarity of documentation.

Provide new functions to allow applications to access/update parts of
coap_pdu_t as appropriate and document as appropriate.

Update examples to use these new access functions where appropriate.
This commit is contained in:
Jon Shallow committed 2021-04-20 10:31:14 +01:00
1 parent b9989ef485
commit e4e067e5fb
42 files changed
+1456 -749

No files matched your search

+2 -5
View File
@@ -56,13 +56,10 @@ make_pdu( unsigned int value ) {
static unsigned char buf[20];
int len, ls;
if (!(pdu = coap_pdu_init(0, 0, 0, COAP_DEFAULT_MTU)))
if (!(pdu = coap_pdu_init(COAP_MESSAGE_NON, COAP_REQUEST_POST, id++,
COAP_DEFAULT_MTU)))
return NULL;
pdu->type = COAP_MESSAGE_NON;
pdu->code = COAP_REQUEST_POST;
pdu->mid = id++;
enc = COAP_PSEUDOFP_ENCODE_8_4_DOWN(value, &ls);
len = sprintf((char *)buf, "%c%u", enc, COAP_PSEUDOFP_DECODE_8_4(enc));