I'm doing a project that involves sending RTCP packets with arduino and the way I create the packets I want to send is that I build the packets from different header components using strcat etc. My problem is that the RTCP header includes a 16bit length-field that might have a value that's less than 0x0100(hex) and when you convert that to two string characters, the more significant char will have a value of 00. Now the length field is in the middle of the packet and the packet being a string it doesn't really want to work with nulls, it being null terminated by definition. So my question is how can I approach this problem? When I append the packet with characters including a null it won't take that into consideration.
Atleast the UDP library has the option of sending data that contains 0x00 bytes.
/* Send packet contained in buf of length len to peer at specified ip, and port */
/* Use this function to transmit binary data that might contain 0x00 bytes*/
/* This function returns sent data size for success else -1. */
uint16_t UdpClass::sendPacket(uint8_t sock, uint8_t * buf, uint16_t len, uint8_t * ip, uint16_t port)
Oh and if you are wondering about the "sock" I've made a few changes to the UDP library.