transmitting a database as a struct #225
-
Hi, I want to send a database of information to neighbouring nodes in a network so that eventually, all the nodes have a complete database with all the data from all the nodes. I believe that the function
Is my goal possible to achieve? If not, what other ways could I transmit larger sizes of data in LoRa? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
No, it takes an uint8_t pointer - so it can send anything if you cast it to that pointer. Which makes sense - after all, your struct is just a bunch of bytes, which is what the radio is sending. It's perfectly fine to do the following (if some it is unclear, I suggest reading up on pointers): typedef struct
{
uint16_t nodeID;
uint8_t event;
uint32_t timestamp;
} databaseEntry;
databaseEntry entry = {
.nodeID = 1,
.event = 2,
.timestamp = 3,
}
uint8_t* entryPtr = (uint8_t*)&entry;
transmit(entryPtr, sizeof(databaseEntry)); |
Beta Was this translation helpful? Give feedback.
No, it takes an uint8_t pointer - so it can send anything if you cast it to that pointer. Which makes sense - after all, your struct is just a bunch of bytes, which is what the radio is sending.
It's perfectly fine to do the following (if some it is unclear, I suggest reading up on pointers):