Skip to content

transmitting a database as a struct #225

Answered by jgromes
sto1cLem0n5 asked this question in Q&A
Discussion options

You must be logged in to vote

can only take a uint8_t variable

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));

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sto1cLem0n5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants