Need help on how to deal with this

Hi everyone.
I made a struct:

struct Data_Package {
  int a = 1011;
  int b = 1010;
  int c = 2011;
  int d = 2010;
  int e = 3011;
  int f = 3010;
  int g = 4011;
  int h = 4010;
};

I need NRF to send entirety of the Data_Package some time; part of the whole Data_Package some time; even just 1 data some time.
such as:

struct Data_Package {
  int a = 1011;
//  int b = 1010;
  int c = 2011;
  int d = 2010;
  int e = 3011;
  int f = 3010;
  int g = 4011;
  int h = 4010;
};

OR:

struct Data_Package {
  int a = 1011;
  int b = 1010;
  int c = 2011;
  int d = 2010;
//  int e = 3011;
  int f = 3010;
  int g = 4011;
  int h = 4010;
};

OR:

struct Data_Package {
  int a = 1011;
  int b = 1010;
  int c = 2011;
  int d = 2010;
//  int e = 3011;
  int f = 3010;
  int g = 4011;
//  int h = 4010;
};

OR:

struct Data_Package {
//  int a = 1011;
  int b = 1010;
//  int c = 2011;
//  int d = 2010;
//  int e = 3011;
//  int f = 3010;
//  int g = 4011;
//  int h = 4010;
};

are there any easy way to do it please?
Thanks
Adam

Why? It would be much simpler for you to just send the whole struct everytime.

2 Likes

You could include a bit mask variable that flags new/changed data.

1 Like

What platform are you using ? With a 32 bit platform (with 32 bit integers) you'd be at the limit of what you could send in a single packet (max 32 bytes).

Anyway, the advice to send the "worst case", that is all data on every transmission, is good.

1 Like

Thanks.
for different receiver.

Thanks.
Used MEGA2560.

"Data Package" doesn't seem like a valid description of a message if it is not the same on both devices.

of course sending a (packed) struct is a convenient approach for sending data of various size and format.

but more flexible approach is sending TLVs (type, length, value(s)). one or more TLVs can be sent in a message. the receiver identifies the data by type and can further validate it by length (or skip over it by length) before copying it into a local variable.

a table would be used by the receiver to map the received data to a pointer to the local variable. new TLVs could easily be handled by new table entries, not changes in logic

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.