Build the raw byte message ahead of transmitting it
This commit is contained in:
parent
34bee82abe
commit
04cc89ea50
1 changed files with 16 additions and 3 deletions
|
@ -49,10 +49,23 @@ void setup() {
|
||||||
// Activate the RFM95
|
// Activate the RFM95
|
||||||
peripheral_switch(PIN_SPI_CS_SD, PIN_SPI_CS_RFM95);
|
peripheral_switch(PIN_SPI_CS_SD, PIN_SPI_CS_RFM95);
|
||||||
|
|
||||||
uint8_t message[] = "testing";
|
const uint8_t message_size = sizeof(uint32_t) + sizeof(float)*2;
|
||||||
|
uint8_t message[message_size];
|
||||||
|
|
||||||
// transmit_init();
|
const uint8_t* bytes_id = reinterpret_cast<uint8_t const *>(&id);
|
||||||
// transmit_send(message, 7);
|
const uint8_t* bytes_lat = reinterpret_cast<uint8_t const *>(&(gps_data.lat));
|
||||||
|
const uint8_t* bytes_lng = reinterpret_cast<uint8_t const *>(&(gps_data.lat));
|
||||||
|
|
||||||
|
for(int i = 0; i < sizeof(uint32_t); i++) {
|
||||||
|
message[i] = bytes_id[i];
|
||||||
|
}
|
||||||
|
for(int i = 0; i < sizeof(float); i++) {
|
||||||
|
message[sizeof(uint32_t) + i] = bytes_lat[i];
|
||||||
|
message[sizeof(uint32_t) + sizeof(float) + i] = bytes_lng[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
transmit_init();
|
||||||
|
transmit_send(message, message_size);
|
||||||
|
|
||||||
|
|
||||||
power_off(); // Doesn't return
|
power_off(); // Doesn't return
|
||||||
|
|
Loading…
Reference in a new issue