Hi,
I'm using an Arduino library for a radio.
If you do crtl+f and for "Transmission without ACK" you will see example code.
There is a function called sendPacketTimeout(). This function takes a destination and payload packet of type char, for example like this.
char message1 [] = "Hello";
void setup()
{
}
void loop(void)
{
e = sx1272.sendPacketTimeout(8, message1);
}
I've copied the sendPacketTimeout() function declaration from the header file below.
Questions
- Can you only pass a char to the function?
- Could I create a struct with information and pass that to the function for example like this.
struct messagePacket {
char boardID[3];
char temperature[3];
char humidity[3];
};
struct messagePacket myPacket;
void setup() {
struct messagePacket myPacket;
Serial.begin(9600);
strcpy(myPacket.boardID, "01");
strcpy(myPacket.temperature, "75");
strcpy(myPacket.humidity, "90");
e = sx1272.sendPacketTimeout(8, myPacket;
This the function declaration from the library
uint8_t sendPacketTimeout(uint8_t dest, char *payload);
//! It sends the packet wich payload is a parameter before ending MAX_TIMEOUT.
/*!
\param uint8_t dest : packet destination.
\param uint8_t *payload: packet payload.
\param uint16_t length : payload buffer length.
\return '0' on success, '1' otherwise
*/
uint8_t sendPacketTimeout(uint8_t dest, uint8_t *payload, uint16_t length);
//! It sends the packet wich payload is a parameter before ending 'wait' time.
/*!
\param uint8_t dest : packet destination.
\param char *payload : packet payload.
\param uint16_t wait : time to wait.
\return '0' on success, '1' otherwise
*/