hirotakaster / CoAP-simple-library

Other
111 stars 48 forks source link

Convert IPaddress to string using a char array instead of a String #14

Closed alexmrqt closed 4 years ago

alexmrqt commented 4 years ago

Any IPv4 address can be represented as a string between 16 (15 + '\0') and 8 (7 + '\0') characters :

Memory fragmentation due to String allocation can cause crash or undefined behaviors in microcontrollers. This is especially true for very constrained device like the atmega328p in the Arduino Uno.

This PR address this issue by changing the type of ipaddress to char[16], allowing for static memory allocation. int -> string conversion is then handled by sprintf().

alexmrqt commented 4 years ago

Note that this was also proposed in #5 :)

hirotakaster commented 4 years ago

@alexmrqt thank you for your pull request.