rf24network and struct,s

Hi, whilst I have been playing with Arduino's for a couple of years now I still only rate myself as a novice, so please bear that in mind.

I am building a small home network based on the excellent rf24network library in order to monitor a few Arduino devices around the property. I have done the Base station and one node in my polytunnel which works the irrigation in 4 sections and monitors the temperatures inside, outside and in the propagator, sending all the data back to the house and displaying on a TFT screen with no problems.

The data is sent back as a Struct as the variables are float and integers mixed but as I add more nodes the data will vary in both data types and amounts of variables, and as it seems I can only define one Struct which has to be the same at each end I am puzzled by how I can define a different Struct for each node in the base station. Do I define a universal Struct and only fill in and extract the variables I need. I know I can determine the node of origin by reading the header and could call a function to extract what is required, but I think maybe there is a more sophisticated and better way of doing this.

I have tried reading the header and calling a function to define a different Struct but this did not seem to work. I hope I have made my problem clear and that someone will be able to point me in a "not too difficult" direction.

Peter

I suggest you study the concept of a union. A union allows you to access the same block of data in different ways. I think you could create a system in which the data received would go into (say) a 32 byte space and when the data has come from SlaveA you could treat it as several floats and when it comes from SlaveB you treat it as several ints (or any mixture of types that you need.

...R

Robin2:
I suggest you study the concept of a union. A union allows you to access the same block of data in different ways. I think you could create a system in which the data received would go into (say) a 32 byte space and when the data has come from SlaveA you could treat it as several floats and when it comes from SlaveB you treat it as several ints (or any mixture of types that you need.

...R

Thanks for the reply Robin, I have heard of Unions but have never studied them, from what you say I take it that the payload is dumped into memory and the data interpreted differently depending on where it came from i.e if it came from Node 1 it could be interpreted as one set of mixed floats and ints and from Node 2 a different set, am I correct in that.

I think I shall have to do some work on that concept as it sound very interesting.

Many thanks

Peter

Pwagg:
i.e if it came from Node 1 it could be interpreted as one set of mixed floats and ints and from Node 2 a different set, am I correct in that.

Yes.

Of course your receiver will need to know where the data came from so it can use the correct interpretation.

...R