Skip to content

Commit

Permalink
Modifications for 64-bit OS (#218)
Browse files Browse the repository at this point in the history
* Modifications for 64-bit OS

* Change unsigned long to uint32_t in examples

* Modify printf in example: Change %lu to %u

* run clang-format v12.0.1 on unchanged some files

---------

Co-authored-by: Brendan <[email protected]>
  • Loading branch information
TMRh20 and 2bndy5 committed Feb 16, 2024
1 parent 4e804ee commit 179e0c0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
16 changes: 12 additions & 4 deletions RF24Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1181,14 +1181,22 @@ template<class radio_t>
uint64_t ESBNetwork<radio_t>::pipe_address(uint16_t node, uint8_t pipe)
{

static uint8_t address_translation[] = {0xc3, 0x3c, 0x33, 0xce, 0x3e, 0xe3, 0xec
static uint8_t address_translation[] = { 0xc3,
0x3c,
0x33,
0xce,
0x3e,
0xe3,
0xec
#if NUM_PIPES > 6
, 0xee
,
0xee
#if NUM_PIPES > 7
, 0xed
,
0xed
#endif
#endif
};
};
uint64_t result = 0xCCCCCCCCCCLL;
uint8_t* out = reinterpret_cast<uint8_t*>(&result);

Expand Down
2 changes: 1 addition & 1 deletion RF24Network_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
/** Enable dynamic payloads - If using different types of nRF24L01 modules, some may be incompatible when using this feature **/
#define ENABLE_DYNAMIC_PAYLOADS
#endif // DISABLE_DYNAMIC_PAYLOADS

/** The number of 'pipes' available for addressing in the current device
* Networks with NRF24L01 devices only have 6 pipes
* NRF52x networks support up to 8 pipes
Expand Down
6 changes: 3 additions & 3 deletions examples_RPi/helloworld_rx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const uint16_t other_node = 01;

struct payload_t
{ // Structure of our payload
unsigned long ms;
unsigned long counter;
uint32_t ms;
uint32_t counter;
};

int main(int argc, char** argv)
Expand All @@ -56,7 +56,7 @@ int main(int argc, char** argv)
payload_t payload;
network.read(header, &payload, sizeof(payload));

printf("Received payload: counter=%lu, origin timestamp=%lu\n", payload.counter, payload.ms);
printf("Received payload: counter=%u, origin timestamp=%u\n", payload.counter, payload.ms);
}
//sleep(2);
delay(2000);
Expand Down
10 changes: 5 additions & 5 deletions examples_RPi/helloworld_tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ const uint16_t other_node = 00;
// How often (in milliseconds) to send a message to the `other_node`
const unsigned long interval = 2000;

unsigned long last_sent; // When did we last send?
unsigned long packets_sent; // How many have we sent already
uint32_t last_sent; // When did we last send?
uint32_t packets_sent; // How many have we sent already

struct payload_t
{ // Structure of our payload
unsigned long ms;
unsigned long counter;
uint32_t ms;
uint32_t counter;
};

int main(int argc, char** argv)
Expand All @@ -58,7 +58,7 @@ int main(int argc, char** argv)
while (1) {

network.update();
unsigned long now = millis(); // If it's time to send a message, send it!
uint32_t now = millis(); // If it's time to send a message, send it!
if (now - last_sent >= interval) {
last_sent = now;

Expand Down
6 changes: 3 additions & 3 deletions examples_RPi/rx-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ const uint16_t other_node = 01;

struct payload_power_t
{ // Structure of our payload
unsigned long nodeId;
uint32_t nodeId;
float power;
float current;
};

struct payload_weather_t
{
unsigned long nodeId;
uint32_t nodeId;
float temperature;
float humidity;
unsigned long lux;
uint32_t lux;
};

int main(int argc, char** argv)
Expand Down

0 comments on commit 179e0c0

Please sign in to comment.