Faulty connection / Connects once then drops

If you need multiple distinct packet types, you should probably use the “port” number which you are already “paying” to send in order to tell them apart.

But its best to put multiple measurements in a single packet.

Often you would do this with a struct, and then pass a pointer to the struct and its size to the send function.

Struct packing can get tricky between computer types but will probably be sane with your platform if you do one specific thing, and that is start with the larger data types and move to the smaller ones.

So for example

struct measurements {

  uint32_t something big;
  uint16_t something medium;
  uint8_t something_small;
  uint8_t another_small;

};

2 Likes