Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [wakaama-dev] [leshan-dev] Leshan Issue with Content-Format following update to M15

Hi Riccardo,
Based on the fact it appears to only be copying 1 byte, certain compilers, especially for embedded processors, such as IAR, try to be "smart" and optimize the struct's size, such as for enumerators.  IAR looks at all the values defined in the enum and if the value's do not exceed 255, it will give the enum a size of 1 byte in the structure.  So even though lwm2m_media_type_t has the correct size, once it type casts lwm2m_media_type_t into coap_content_type_t, you lose 1 byte, therefore 11542 turns into 22.

We've tried a few different solutions on our side, ultimately we added a value to the coap_content_type_t enum forcing IAR to give it a size of at least 2 bytes:

/* CoAP Content-Types */
typedef enum {
...
...
  APPLICATION_SOAP_FASTINFOSET = 49,
  APPLICATION_JSON = 50,
  APPLICATION_X_OBIX_BINARY = 51,
  FORCE_ENUM_SIZE_4_BYTES= 65535  // Added to force IAR to assign at least 2 bytes to struct coap_packet_t as lwm2m content type(lwm2m_media_type_t) require at least 2 bytes.
} coap_content_type_t;

Anyways my colleague posted about this several months ago:
https://dev.eclipse.org/mhonarc/lists/wakaama-dev/msg00279.html

I hope this solves your issue.

David
________________________________
NOTICE OF CONFIDENTIALITY:
This message may contain information that is considered confidential and which may be prohibited from disclosure under applicable law or by contractual agreement. The information is intended solely for the use of the individual or entity named above. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of the information contained in or attached to this message is strictly prohibited. If you have received this email transmission in error, please notify the sender by replying to this email and then delete it from your system.


Back to the top