From 179e0c00111f754850dedcb47a0dfda56f459f86 Mon Sep 17 00:00:00 2001 From: TMRh20 Date: Fri, 16 Feb 2024 07:36:19 -0600 Subject: [PATCH] Modifications for 64-bit OS (#218) * 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 <2bndy5@gmail.com> --- RF24Network.cpp | 16 ++++++++++++---- RF24Network_config.h | 2 +- examples_RPi/helloworld_rx.cpp | 6 +++--- examples_RPi/helloworld_tx.cpp | 10 +++++----- examples_RPi/rx-test.cpp | 6 +++--- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/RF24Network.cpp b/RF24Network.cpp index b58e9bed..fafe1ce6 100644 --- a/RF24Network.cpp +++ b/RF24Network.cpp @@ -1181,14 +1181,22 @@ template uint64_t ESBNetwork::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(&result); diff --git a/RF24Network_config.h b/RF24Network_config.h index 5968a305..33513c86 100644 --- a/RF24Network_config.h +++ b/RF24Network_config.h @@ -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 diff --git a/examples_RPi/helloworld_rx.cpp b/examples_RPi/helloworld_rx.cpp index 520338af..2f933d7e 100644 --- a/examples_RPi/helloworld_rx.cpp +++ b/examples_RPi/helloworld_rx.cpp @@ -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) @@ -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); diff --git a/examples_RPi/helloworld_tx.cpp b/examples_RPi/helloworld_tx.cpp index 1e5fe779..6352133a 100644 --- a/examples_RPi/helloworld_tx.cpp +++ b/examples_RPi/helloworld_tx.cpp @@ -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) @@ -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; diff --git a/examples_RPi/rx-test.cpp b/examples_RPi/rx-test.cpp index df4372bb..6e188a85 100644 --- a/examples_RPi/rx-test.cpp +++ b/examples_RPi/rx-test.cpp @@ -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)