Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set node Id cause problem in connecting #137

Closed
fireghostea opened this issue Nov 15, 2017 · 33 comments
Closed

Set node Id cause problem in connecting #137

fireghostea opened this issue Nov 15, 2017 · 33 comments
Labels

Comments

@fireghostea
Copy link

fireghostea commented Nov 15, 2017

i explain my problem completely in this video
https://youtu.be/uxRRYpss-Ew

@fireghostea fireghostea changed the title SetnodeId cause problem in connecting Set node Id cause problem in connecting Nov 15, 2017
@Zuputmer
Copy link

Hey, were you able to find a solution to this problem?

@TMRh20
Copy link
Member

TMRh20 commented May 10, 2019

No idea on this one still.

@Doubletop12
Copy link

Is this in any way connected with the problem I have?

If I am running more than 5 nodes in a mesh with an RPi as the master and Arduino as the slaves restarting everything I will have one of the nodes struggling to connect. It may occasionally get in but soon drops out again and then can't reconnect. Deleting dhcplist.txt on the RPi fixes the problem. Subsequent restarts and the problem comes back, but maybe not immeadiatly.

I have seriously considered having the code delete dhcplist.txt on startup, but felt it was a retrograde step. The dhcplist is there for a reason.

Pete

@2bndy5
Copy link
Member

2bndy5 commented May 9, 2023

Do you know if the node struggles on net level 1 more than a higher level? I don't think the problem is with the dhcplist.txt.

BTW, @Doubletop12 you should open a new issue. Based on what you describe, I don't think this issue is actually related. It might also help to know the exact hardware used (eg RPi variant, Arduino variant, if radio module is PA/LNA or not, etc).

@naty6458
Copy link

naty6458 commented Mar 2, 2024

Debugging when the controller is up

image

Debugging when requesting a new address, without initializing the controller.
image

This is a memory overflow into network.frame_buffer .
When the controller goes up there is no problem, then when running garbage enters this memory cell.
I am looking for a solution to the problem and will update.

update: When I ignore the byte in the 9th place (network.frame_buffer[9] ), everything works out, but I understand that this is not the final solution, we need to find out why the addresses smaller than 1 BYTE are garbage.

@TMRh20
Copy link
Member

TMRh20 commented Mar 2, 2024

@naty6458 Hey there, I'm a little confused on exactly how you are encountering this issue, can you explain a bit more or provide steps to recreate it?

@naty6458
Copy link

naty6458 commented Mar 2, 2024

When I boot to the microcontroller, getting the addresses works fine.
And when entering the requestAddress function without initializing the controller, entering the BYTE ARRAY type variable named network.frame_buffer in the 9th place is garbage.
This causes obtaining an address that is one BYTE in size (for example 04 01 044 ....) to insert another address that is invalid.

image

@TMRh20
Copy link
Member

TMRh20 commented Mar 2, 2024

Thats what I don't understand, if you haven't initialized the controller, the code should never get to that point...

@naty6458
Copy link

naty6458 commented Mar 2, 2024

But the fact is that it does get there, there must be some kind of bug.
I specifically use the library with STM32 so there may be some adjustment that I didn't do properly, but there is an example where someone initially uploaded the thread that he uses with ARDUINO and the problem also appears with him.(https://youtu.be/uxRRYpss-Ew)

@TMRh20
Copy link
Member

TMRh20 commented Mar 2, 2024

In the video I would suggest simple hardware problems or something like that, I don't see it returning bad values.

In commenting out the setNodeID, the OP is simply creating two master nodes on the same channel which may communicate, but is unsupported.
Are you also commenting out setNodeID() to get it functioning?

@naty6458
Copy link

naty6458 commented Mar 2, 2024

image

image

If sending the message fails + checkConnection = fasle = , I perform SETUP again.
And regarding your question about the setNodeID() I tried with calling it in SETUP and also tried without. no change .

Only when I skip this BYTE everything works fine

image

@TMRh20
Copy link
Member

TMRh20 commented Mar 2, 2024

And regarding your question about the setNodeID() I tried with calling it in SETUP and also tried without. no change .

Hmm, there should be a change, regardless of this issue. The code will not work properly without a valid nodeID.
Are you able to test with one of the included examples and see if you can reproduce the issue because I'm kind of lost in recreating an issue?

@naty6458
Copy link

naty6458 commented Mar 2, 2024

I used the example here in GIT .

https://github.com/nRF24/RF24Mesh/blob/master/examples/RF24Mesh_Example/RF24Mesh_Example.ino

The syntax is slightly different but the logic is exactly the same, so it can be seen in DEBUGING that an unwanted value enters the address. (I have attached a photo)

image

image

@2bndy5
Copy link
Member

2bndy5 commented Mar 3, 2024

I'm also having trouble understanding the issue posed by @naty6458. It would have been better to create a new issue because I fail to see how the original issue and @naty6458 issue are related.

@naty6458 Your issue might be due to byte alignment differences in the various MCUs that you are using. Are all nodes running from a STM32? BTW, STM32 is a vague description. Which exact STM32 chip(s) are you using (ie STM32F103C8 for blue pill, STM32F411CEU6 for black pill)?

@naty6458
Copy link

naty6458 commented Mar 3, 2024

First, sorry for the rush.
Here is the board I use.

https://stm32-base.org/boards/STM32F407VET6-STM32-F4VE-V2.0.html

@2bndy5
Copy link
Member

2bndy5 commented Mar 3, 2024

for all nodes? Or are you using an RPi for another node?

@naty6458
Copy link

naty6458 commented Mar 3, 2024

My network setup is like this.

  1. MASTER which is RASPBERRY PI 3 with pyRF24
  2. NODE which is RASPBERRY PI 3 with pyRF24
  3. NODE which is with the STM32 chip.

Between the RPI everything works fine.
(And this is after I lowered the speed of the SPI to 4MHZ)

@2bndy5
Copy link
Member

2bndy5 commented Mar 3, 2024

And this is after I lowered the speed of the SPI to 4MHZ

for all nodes? Sorry, I'm still trying to extract the steps to reproduce. I don't have a STM32F407 to test.

@naty6458
Copy link

naty6458 commented Mar 3, 2024

image

This line solved the problem. I check the new address level.
If it is one level above the NODE address that offered the address. I get the address.
If not (it's illegal) I ignore the BYTE in the 9th position of the BUFFER.

@naty6458
Copy link

naty6458 commented Mar 3, 2024

And this is after I lowered the speed of the SPI to 4MHZ

for all nodes? Sorry, I'm still trying to extract the steps to reproduce. I don't have a STM32F407 to test.

for both RPI , i change the spi speed to 4MHZ

@2bndy5
Copy link
Member

2bndy5 commented Mar 3, 2024

I'm curious to see if what master is sending back as the assigned address is the same address received.

Do you have debugging enabled on master? You would have to build pyRF24 from source. See the hint in "Using a Specific RF24 driver".

@naty6458
Copy link

naty6458 commented Mar 3, 2024

You are absolutely right, it is very interesting to see what the MASTER really sends.
I will try to compile it with DEBUG enabled and update.

But in my opinion it is not related to him because when I restart the STM I get 0X00 in this BYTE. That's why it indicated to me the problem with the controller.

Nevertheless, I will try to match it with the MASTER

Just so you understand how it works for me now nicely, I lowered the TIMEOUT to 25 ms.. :-)

@2bndy5
Copy link
Member

2bndy5 commented Mar 3, 2024

I fear that your fix introduces a regression for nodes requesting an address directly from net level 1. But I need to see real code (not some pictures of snippet that leave out other modifications).

But in my opinion it is not related to him

My concern is that the RPi is sending a byte-aligned structure and the STM32 is not using a byte-aligned struct to receive it.

@naty6458
Copy link

naty6458 commented Mar 3, 2024

I'm curious to see if what master is sending back as the assigned address is the same address received.

Do you have debugging enabled on master? You would have to build pyRF24 from source. See the hint in "Using a Specific RF24 driver".

image

Indeed, as we thought, I do not receive it from the MASTER, I printed everything that came in from the SPI.

@2bndy5
Copy link
Member

2bndy5 commented Mar 3, 2024

Indeed, as we thought, I do not receive it from the MASTER

Just so I understand perfectly, does this mean that the address sent in byte 8 and 9 (by RPi master) is not the same address received in byte 8 and 9 (by STM32)?

@naty6458
Copy link

naty6458 commented Mar 3, 2024

Very true, I found the problem from the root about you.
What I received from the SPI did not pass accurately to the functions that called the basic function, RF24::read_payload, I fixed it and now everything works.

image

after fix

image

Now I run the original RF24Mesh.cpp file without changes and everything works. Thank you very much!

@naty6458
Copy link

naty6458 commented Mar 3, 2024

nrf24l01_stm32.zip

If it is interesting and you want to add support for ST. I shared the files that work for me now with MESH.
Thank you very much indeed.

I remembered a very important thing that I added to RPI...

ON MASTER LOOP:

time.sleep(sys.float_info.min)

try:
    while True:

        mesh.update()
        mesh.dhcp()

        while network.available():
            header, payload = network.read()
            print(f"Received message {header.to_string()}")
        time.sleep(sys.float_info.min)
except KeyboardInterrupt:
    print("powering down radio and exiting.")
    radio.power = False

ON NODE LOOP:

time.sleep(sys.float_info.min)

try:
    while True:
        # Call mesh.update to keep the network updated
        mesh.update()

        if (millis() - TIMER) >= 1000:
            TIMER = millis()

            if not mesh.write(struct.pack("L", TIMER), ord("M")):
                # If a write fails, check connectivity to the mesh network
                if not mesh.check_connection():
                    # The address could be refreshed per a specified time frame
                    # or only when sequential writes fail, etc.
                    print("Send fail. Renewing Address...")
                    while mesh.renew_address() == MESH_DEFAULT_ADDRESS:
                        print("Renewing Address...")
                else:
                    print("Send fail, Test OK")
            else:
                print("Send OK:", TIMER)
        time.sleep(sys.float_info.min)
except KeyboardInterrupt:
    print("powering down radio and exiting.")
    radio.power = False

@2bndy5
Copy link
Member

2bndy5 commented Mar 3, 2024

If it is interesting and you want to add support for ST. I shared the files that work for me now with MESH.

We already do support STM32 platforms

"ststm32"

But we are restricted to functionality in the Arduino framework.

Given the zip file you posted, I don't see a meaningful fix in the RF24Mesh sources

your patch for RF24Mesh

diff --git a/RF24Mesh.h b/RF24Mesh.h
index a1223ea..87ffced 100644
--- a/RF24Mesh.h
+++ b/RF24Mesh.h
@@ -26,7 +26,7 @@
 #define MESH_ADDR_RELEASE 197
 #define MESH_ID_LOOKUP    198

-#define MESH_BLANK_ID 65535
+#define MESH_BLANK_ID 0xffff

 #if defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny84__)
     #define RF24_TINY
diff --git a/RF24Mesh_config.h b/RF24Mesh_config.h
index 303746e..c163272 100644
--- a/RF24Mesh_config.h
+++ b/RF24Mesh_config.h
@@ -21,7 +21,7 @@
 #endif

 // un-comment for non-master nodes not running on ATTiny MCUs
-//#define MESH_NOMASTER
+#define MESH_NOMASTER

 /***Advanced User Config***/
 /**
@@ -38,7 +38,7 @@
  * @see RF24Mesh::renewAddress()
  */
 #ifndef MESH_RENEWAL_TIMEOUT
-    #define MESH_RENEWAL_TIMEOUT 7500
+    #define MESH_RENEWAL_TIMEOUT 30
 #endif // MESH_RENEWAL_TIMEOUT

 /**
@@ -57,7 +57,7 @@
 /**************************/
 /***       Debug        ***/
 //#define MESH_DEBUG_MINIMAL /** Uncomment for the Master Node to print out address assignments as they are assigned */ 
-//#define MESH_DEBUG         /** Uncomment to enable debug output to serial **/
+#define MESH_DEBUG         /** Uncomment to enable debug output to serial **/
 /**************************/

 /*** Other Configuration ***/

The only changes you made to RF24Network are mostly superfluous except removing the radio.isValid() call in RF24Network::begin() (not a good idea)

your patch for RF24Network

diff --git a/RF24Network.cpp b/RF24Network.cpp
index d6edab8..d0c5d8d 100644
--- a/RF24Network.cpp
+++ b/RF24Network.cpp
@@ -7,6 +7,7 @@
  */
 #include "RF24Network_config.h"
 
+
 #if defined(RF24_LINUX)
     #include <stdlib.h>
     #include <stdio.h>
@@ -78,8 +79,8 @@ void ESBNetwork<radio_t>::begin(uint8_t _channel, uint16_t _node_address)
 
     node_address = _node_address;
 
-    if (!radio.isValid())
-        return;
+//    if (!radio.isValid())
+//        return;
 
     // Set up the radio the way we want it to look
     if (_channel != USE_CURRENT_CHANNEL)
@@ -103,7 +104,7 @@ void ESBNetwork<radio_t>::begin(uint8_t _channel, uint16_t _node_address)
     setup_address();
 
     // Open up all listening pipes
-    uint8_t i = NUM_PIPES;
+    uint8_t i = 6;
     while (i--)
         radio.openReadingPipe(i, pipe_address(_node_address, i));
 
@@ -139,7 +140,7 @@ uint8_t ESBNetwork<radio_t>::update(void)
             break;
         }
 #if defined(ENABLE_DYNAMIC_PAYLOADS) && !defined(XMEGA_D3)
-        frame_size = radio.getDynamicPayloadSize();
+        frame_size = radio.getDynamicPayloadSize()  ;
 #else
         frame_size = MAX_FRAME_SIZE;
 #endif
@@ -150,6 +151,7 @@ uint8_t ESBNetwork<radio_t>::update(void)
         // Read the beginning of the frame as the header
         RF24NetworkHeader* header = (RF24NetworkHeader*)(&frame_buffer);
 
+
         // Throw it away if it's not a valid address or too small
         if (frame_size < sizeof(RF24NetworkHeader) || !is_valid_address(header->to_node) || !is_valid_address(header->from_node)) {
             continue;
@@ -163,7 +165,7 @@ uint8_t ESBNetwork<radio_t>::update(void)
             IF_SERIAL_DEBUG_FRAGMENTATION_L2(printf_P(PSTR("%u: FRG Rcv frame "), millis()); const char* charPtr = reinterpret_cast<const char*>(frame_buffer); for (uint16_t i = 0; i < frame_size; i++) { printf_P(PSTR("%02X "), charPtr[i]); }; printf_P(PSTR("\n\r")));
         }
 #else
-        IF_SERIAL_DEBUG(const uint16_t* i = reinterpret_cast<const uint16_t*>(frame_buffer + sizeof(RF24NetworkHeader)); printf_P(PSTR("NET message %04x\n\r"), *i));
+//        IF_SERIAL_DEBUG(const uint16_t* i = reinterpret_cast<const uint16_t*>(frame_buffer + sizeof(RF24NetworkHeader)); printf_P(PSTR("NET message %04x\n\r"), *i));
 #endif
 
         returnVal = header->type;
@@ -187,14 +189,14 @@ uint8_t ESBNetwork<radio_t>::update(void)
                 continue;
             }
             if ((returnSysMsgs && header->type > MAX_USER_DEFINED_HEADER_TYPE) || header->type == NETWORK_ACK) {
-                IF_SERIAL_DEBUG_ROUTING(printf_P(PSTR("MAC System payload rcvd %d\n"), returnVal););
+//                IF_SERIAL_DEBUG_ROUTING(printf_P(PSTR("MAC System payload rcvd %d\n"), returnVal););
                 if (header->type != NETWORK_FIRST_FRAGMENT && header->type != NETWORK_MORE_FRAGMENTS && header->type != EXTERNAL_DATA_TYPE && header->type != NETWORK_LAST_FRAGMENT) {
                     return returnVal;
                 }
             }
 
             if (enqueue(header) == 2) { //External data received
-                IF_SERIAL_DEBUG_MINIMAL(printf_P(PSTR("ret ext\n")););
+//                IF_SERIAL_DEBUG_MINIMAL(printf_P(PSTR("ret ext\n")););
                 return EXTERNAL_DATA_TYPE;
             }
         }
@@ -220,7 +222,7 @@ uint8_t ESBNetwork<radio_t>::update(void)
                 uint8_t val = enqueue(header);
 
                 if (multicastRelay) {
-                    IF_SERIAL_DEBUG_ROUTING(printf_P(PSTR("MAC FWD multicast frame from 0%o to level %u\n"), header->from_node, _multicast_level + 1););
+//                    IF_SERIAL_DEBUG_ROUTING(printf_P(PSTR("MAC FWD multicast frame from 0%o to level %u\n"), header->from_node, _multicast_level + 1););
                     if ((node_address >> 3) != 0) {
                         // for all but the first level of nodes, those not directly connected to the master, we add the total delay per level
                         delayMicroseconds(600 * 4);
@@ -420,7 +422,7 @@ uint8_t ESBNetwork<radio_t>::enqueue(RF24NetworkHeader* header)
     bool result = false;
     uint16_t message_size = frame_size - sizeof(RF24NetworkHeader);
 
-    IF_SERIAL_DEBUG(printf_P(PSTR("NET Enqueue @%x\n"), next_frame - frame_queue));
+//    IF_SERIAL_DEBUG(printf_P(PSTR("NET Enqueue @%x\n"), next_frame - frame_queue));
 
     #if !defined(DISABLE_FRAGMENTATION)
 
@@ -433,7 +435,7 @@ uint8_t ESBNetwork<radio_t>::enqueue(RF24NetworkHeader* header)
             memcpy((char*)(&frag_queue), &frame_buffer, sizeof(RF24NetworkHeader));
             memcpy(frag_queue.message_buffer, frame_buffer + sizeof(RF24NetworkHeader), message_size);
 
-            IF_SERIAL_DEBUG_FRAGMENTATION(printf_P(PSTR("queue first, total frags %d\n\r"), header->reserved););
+//            IF_SERIAL_DEBUG_FRAGMENTATION(printf_P(PSTR("queue first, total frags %d\n\r"), header->reserved););
             //Store the total size of the stored frame in message_size
             frag_queue.message_size = message_size;
             --frag_queue.header.reserved;
@@ -467,8 +469,8 @@ uint8_t ESBNetwork<radio_t>::enqueue(RF24NetworkHeader* header)
             frag_queue.header.reserved = 0;
             frag_queue.header.type = header->reserved;
 
-            IF_SERIAL_DEBUG_FRAGMENTATION(printf_P(PSTR("fq 3: %d\n"), frag_queue.message_size););
-            IF_SERIAL_DEBUG_FRAGMENTATION_L2(for (int i = 0; i < frag_queue.message_size; i++) { printf_P(PSTR("%02X"), frag_queue.message_buffer[i]); });
+//            IF_SERIAL_DEBUG_FRAGMENTATION(printf_P(PSTR("fq 3: %d\n"), frag_queue.message_size););
+//            IF_SERIAL_DEBUG_FRAGMENTATION_L2(for (int i = 0; i < frag_queue.message_size; i++) { printf_P(PSTR("%02X"), frag_queue.message_buffer[i]); });
 
             // Frame assembly complete, copy to main buffer if OK
             if (frag_queue.header.type == EXTERNAL_DATA_TYPE) {
@@ -487,10 +489,10 @@ uint8_t ESBNetwork<radio_t>::enqueue(RF24NetworkHeader* header)
                     next_frame += 4 - padding;
                 }
         #endif
-                IF_SERIAL_DEBUG_FRAGMENTATION(printf_P(PSTR("enq size %d\n"), frag_queue.message_size););
+//                IF_SERIAL_DEBUG_FRAGMENTATION(printf_P(PSTR("enq size %d\n"), frag_queue.message_size););
                 return true;
             }
-            IF_SERIAL_DEBUG_FRAGMENTATION(printf_P(PSTR("Drop frag payload, queue full\n")););
+//            IF_SERIAL_DEBUG_FRAGMENTATION(printf_P(PSTR("Drop frag payload, queue full\n")););
             return false;
 
         } //If more or last fragments
@@ -531,7 +533,7 @@ uint8_t ESBNetwork<radio_t>::enqueue(RF24NetworkHeader* header)
     }
     else {
         result = false;
-        IF_SERIAL_DEBUG(printf_P(PSTR("NET **Drop Payload** Buffer Full")));
+//        IF_SERIAL_DEBUG(printf_P(PSTR("NET **Drop Payload** Buffer Full")));
     }
     return result;
 }
@@ -644,9 +646,9 @@ uint16_t ESBNetwork<radio_t>::read(RF24NetworkHeader& header, void* message, uin
     if (maxlen > 0) {
         maxlen = rf24_min(maxlen, bufsize);
         memcpy(message, frame_queue + 10, maxlen);
-        IF_SERIAL_DEBUG(printf_P(PSTR("NET message size %d\n"), bufsize););
+//        IF_SERIAL_DEBUG(printf_P(PSTR("NET message size %d\n"), bufsize););
 
-        IF_SERIAL_DEBUG(uint16_t len = maxlen; printf_P(PSTR("NET message ")); const uint8_t* charPtr = reinterpret_cast<const uint8_t*>(message); while (len--) { printf_P(PSTR("%02x "), charPtr[len]); } printf_P(PSTR("\n\r")));
+//        IF_SERIAL_DEBUG(uint16_t len = maxlen; printf_P(PSTR("NET message ")); const uint8_t* charPtr = reinterpret_cast<const uint8_t*>(message); while (len--) { printf_P(PSTR("%02x "), charPtr[len]); } printf_P(PSTR("\n\r")));
     }
     next_frame -= bufsize + 10;
     uint8_t padding = 0;
@@ -702,7 +704,7 @@ bool ESBNetwork<radio_t>::write(RF24NetworkHeader& header, const void* message,
     //Check payload size
 
     if (len > MAX_PAYLOAD_SIZE) {
-        IF_SERIAL_DEBUG(printf_P(PSTR("NET write message failed. Given 'len' %d is bigger than the MAX Payload size %i\n\r"), len, MAX_PAYLOAD_SIZE););
+//        IF_SERIAL_DEBUG(printf_P(PSTR("NET write message failed. Given 'len' %d is bigger than the MAX Payload size %i\n\r"), len, MAX_PAYLOAD_SIZE););
         return false;
     }
 
@@ -711,7 +713,7 @@ bool ESBNetwork<radio_t>::write(RF24NetworkHeader& header, const void* message,
 
     uint8_t msgCount = 0;
 
-    IF_SERIAL_DEBUG_FRAGMENTATION(printf_P(PSTR("FRG Total message fragments %d\n\r"), fragment_id););
+//    IF_SERIAL_DEBUG_FRAGMENTATION(printf_P(PSTR("FRG Total message fragments %d\n\r"), fragment_id););
 
     if (header.to_node != NETWORK_MULTICAST_ADDRESS) {
         networkFlags |= FLAG_FAST_FRAG;
@@ -759,12 +761,12 @@ bool ESBNetwork<radio_t>::write(RF24NetworkHeader& header, const void* message,
         //if(writeDirect != NETWORK_AUTO_ROUTING){ delay(2); } //Delay 2ms between sending multicast payloads
 
         if (!ok && retriesPerFrag >= 3) {
-            IF_SERIAL_DEBUG_FRAGMENTATION(printf_P(PSTR("FRG TX with fragmentID '%d' failed after %d fragments. Abort.\n\r"), fragment_id, msgCount));
+//            IF_SERIAL_DEBUG_FRAGMENTATION(printf_P(PSTR("FRG TX with fragmentID '%d' failed after %d fragments. Abort.\n\r"), fragment_id, msgCount));
             break;
         }
 
         // Message was successful sent
-        IF_SERIAL_DEBUG_FRAGMENTATION_L2(printf_P(PSTR("FRG message transmission with fragmentID '%d' successful.\n\r"), fragment_id));
+//        IF_SERIAL_DEBUG_FRAGMENTATION_L2(printf_P(PSTR("FRG message transmission with fragmentID '%d' successful.\n\r"), fragment_id));
     }
     header.type = type;
     if (networkFlags & FLAG_FAST_FRAG) {
@@ -775,7 +777,7 @@ bool ESBNetwork<radio_t>::write(RF24NetworkHeader& header, const void* message,
     networkFlags &= ~FLAG_FAST_FRAG;
 
     // Return true if all the chunks where sent successfully
-    IF_SERIAL_DEBUG_FRAGMENTATION(printf_P(PSTR("FRG total message fragments sent %i.\r\n"), msgCount););
+//    IF_SERIAL_DEBUG_FRAGMENTATION(printf_P(PSTR("FRG total message fragments sent %i.\r\n"), msgCount););
 
     if (!ok || fragment_id > 0) {
         return false;
@@ -808,7 +810,7 @@ bool ESBNetwork<radio_t>::_write(RF24NetworkHeader& header, const void* message,
 
         memcpy(frame_buffer + sizeof(RF24NetworkHeader), message, len);
 
-        IF_SERIAL_DEBUG(uint16_t tmpLen = len; printf_P(PSTR("NET message ")); const uint8_t* charPtr = reinterpret_cast<const uint8_t*>(message); while (tmpLen--) { printf_P(PSTR("%02x "), charPtr[tmpLen]); } printf_P(PSTR("\n\r")));
+//        IF_SERIAL_DEBUG(uint16_t tmpLen = len; printf_P(PSTR("NET message ")); const uint8_t* charPtr = reinterpret_cast<const uint8_t*>(message); while (tmpLen--) { printf_P(PSTR("%02x "), charPtr[tmpLen]); } printf_P(PSTR("\n\r")));
 #endif
     }
 
@@ -848,7 +850,7 @@ bool ESBNetwork<radio_t>::write(uint16_t to_node, uint8_t sendType)
         isAckType = true;
 
     /*if( ( (frame_buffer[7] % 2) && frame_buffer[6] == NETWORK_MORE_FRAGMENTS) ){
-    isAckType = 0;
+	isAckType = 0;
     }*/
 
     // Throw it away if it's not a valid address
@@ -859,7 +861,7 @@ bool ESBNetwork<radio_t>::write(uint16_t to_node, uint8_t sendType)
     logicalToPhysicalStruct conversion = {to_node, sendType, 0};
     logicalToPhysicalAddress(&conversion);
 
-    IF_SERIAL_DEBUG(printf_P(PSTR("MAC Sending to 0%o via 0%o on pipe %x\n\r"), to_node, conversion.send_node, conversion.send_pipe));
+//    IF_SERIAL_DEBUG(printf_P(PSTR("MAC Sending to 0%o via 0%o on pipe %x\n\r"), to_node, conversion.send_node, conversion.send_pipe));
     /**Write it*/
     if (sendType == TX_ROUTED && conversion.send_node == to_node && isAckType) {
         delay(2);
@@ -867,7 +869,7 @@ bool ESBNetwork<radio_t>::write(uint16_t to_node, uint8_t sendType)
     ok = write_to_pipe(conversion.send_node, conversion.send_pipe, conversion.multicast);
 
     if (!ok) {
-        IF_SERIAL_DEBUG_ROUTING(printf_P(PSTR("MAC Send fail to 0%o via 0%o on pipe %x\n\r"), to_node, conversion.send_node, conversion.send_pipe););
+//        IF_SERIAL_DEBUG_ROUTING(printf_P(PSTR("MAC Send fail to 0%o via 0%o on pipe %x\n\r"), to_node, conversion.send_node, conversion.send_pipe););
     }
 
     if (sendType == TX_ROUTED && ok && conversion.send_node == to_node && isAckType) {
@@ -889,7 +891,7 @@ bool ESBNetwork<radio_t>::write(uint16_t to_node, uint8_t sendType)
         write_to_pipe(conversion.send_node, conversion.send_pipe, conversion.multicast);
 
         // dynLen=0;
-        IF_SERIAL_DEBUG_ROUTING(printf_P(PSTR("MAC Route OK to 0%o ACK sent to 0%o\n"), to_node, header->from_node););
+//        IF_SERIAL_DEBUG_ROUTING(printf_P(PSTR("MAC Route OK to 0%o ACK sent to 0%o\n"), to_node, header->from_node););
     }
 
     if (ok && conversion.send_node != to_node && (sendType == TX_NORMAL || sendType == USER_TX_TO_LOGICAL_ADDRESS) && isAckType) {
@@ -907,7 +909,7 @@ bool ESBNetwork<radio_t>::write(uint16_t to_node, uint8_t sendType)
             delayMicroseconds(900);
 #endif
             if (millis() - reply_time > routeTimeout) {
-                IF_SERIAL_DEBUG_ROUTING(printf_P(PSTR("MAC Network ACK fail from 0%o via 0%o on pipe %x\n\r"), to_node, conversion.send_node, conversion.send_pipe););
+//                IF_SERIAL_DEBUG_ROUTING(printf_P(PSTR("MAC Network ACK fail from 0%o via 0%o on pipe %x\n\r"), to_node, conversion.send_node, conversion.send_pipe););
                 ok = false;
                 break;
             }
@@ -956,7 +958,7 @@ void ESBNetwork<radio_t>::logicalToPhysicalAddress(logicalToPhysicalStruct* conv
         //}
     }
     else if (is_descendant(*to_node)) {
-        pre_conversion_send_pipe = NUM_PIPES - 1; // Send to its listening pipe
+        pre_conversion_send_pipe = 5; // Send to its listening pipe
         // If the node is a direct child,
         if (is_direct_child(*to_node)) {
             // Send directly
@@ -1081,7 +1083,7 @@ void ESBNetwork<radio_t>::setup_address(void)
     }
     parent_pipe = i;
 
-    IF_SERIAL_DEBUG_MINIMAL(printf_P(PSTR("setup_address node=0%o mask=0%o parent=0%o pipe=0%o\n\r"), node_address, node_mask, parent_node, parent_pipe););
+//    IF_SERIAL_DEBUG_MINIMAL(printf_P(PSTR("setup_address node=0%o mask=0%o parent=0%o pipe=0%o\n\r"), node_address, node_mask, parent_node, parent_pipe););
     //  IF_SERIAL_DEBUG_MINIMAL(Serial.print(F("setup_address node=")));
     //  IF_SERIAL_DEBUG_MINIMAL(Serial.print(node_address,OCT));
     //  IF_SERIAL_DEBUG_MINIMAL(Serial.print(F(" parent=")));
@@ -1131,9 +1133,9 @@ bool ESBNetwork<radio_t>::is_valid_address(uint16_t node)
 #endif
     while (node) {
         uint8_t digit = node & 0x07;
-        if (digit < 1 || digit > (NUM_PIPES - 1)) {
+        if (digit < 1 || digit > 5) {
             result = false;
-            IF_SERIAL_DEBUG_MINIMAL(printf_P(PSTR("*** WARNING *** Invalid address 0%o\n\r"), origNode););
+//            IF_SERIAL_DEBUG_MINIMAL(printf_P(PSTR("*** WARNING *** Invalid address 0%o\n\r"), origNode););
             break;
         }
         node >>= 3;
@@ -1141,7 +1143,7 @@ bool ESBNetwork<radio_t>::is_valid_address(uint16_t node)
     }
 
     if (count > 4) {
-        IF_SERIAL_DEBUG_MINIMAL(printf_P(PSTR("*** WARNING *** Invalid address 0%o\n\r"), origNode););
+//        IF_SERIAL_DEBUG_MINIMAL(printf_P(PSTR("*** WARNING *** Invalid address 0%o\n\r"), origNode););
         return false;
     }
     return result;
@@ -1181,22 +1183,7 @@ 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
-#if NUM_PIPES > 6
-                                             ,
-                                             0xee
-    #if NUM_PIPES > 7
-                                             ,
-                                             0xed
-    #endif
-#endif
-    };
+    static uint8_t address_translation[] = {0xc3, 0x3c, 0x33, 0xce, 0x3e, 0xe3, 0xec};
     uint64_t result = 0xCCCCCCCCCCLL;
     uint8_t* out = reinterpret_cast<uint8_t*>(&result);
 
@@ -1222,7 +1209,16 @@ uint64_t ESBNetwork<radio_t>::pipe_address(uint16_t node, uint8_t pipe)
     else
         out[1] = address_translation[count - 1];
 #endif
-    IF_SERIAL_DEBUG(uint32_t* top = reinterpret_cast<uint32_t*>(out + 1); printf_P(PSTR("NET Pipe %i on node 0%o has address %x%x\n\r"), pipe, node, *top, *out));
+
+//	uint8_t * to_address1 = out + 1;
+//	uint8_t * to_address2 = out + 2;
+//	uint8_t * to_address3 = out + 3;
+//	uint8_t * to_address4 = out + 4;
+//	uint8_t * to_address5 = out + 5;
+
+
+//    IF_SERIAL_DEBUG( printf_P(PSTR("NET Pipe %i on node 0%o has address %x%x%x%x%x%x\n\r"), pipe, node, *to_address5 ,*to_address4 , *to_address3 , *to_address2 ,*to_address1, *out));
+
 
     return result;
 }
diff --git a/RF24Network.h b/RF24Network.h
index 38a2da1..0199e02 100644
--- a/RF24Network.h
+++ b/RF24Network.h
@@ -317,9 +317,9 @@ struct RF24NetworkFrame
     uint16_t message_size;
 
 /**
- * On Arduino, the message buffer is just a pointer, and can be pointed to any memory location.
- * On Linux the message buffer is a standard byte array, equal in size to the defined MAX_PAYLOAD_SIZE
- */
+     * On Arduino, the message buffer is just a pointer, and can be pointed to any memory location.
+     * On Linux the message buffer is a standard byte array, equal in size to the defined MAX_PAYLOAD_SIZE
+     */
 #if defined(RF24_LINUX)
     uint8_t message_buffer[MAX_PAYLOAD_SIZE]; // Array to store the message
 #else
@@ -334,15 +334,15 @@ struct RF24NetworkFrame
     RF24NetworkFrame() {}
 
 /**
- * **Constructor for Linux platforms** - create a network frame with data
- * Frames are constructed and handled differently on Arduino/AVR and Linux devices (`#if defined RF24_LINUX`)
- *
- * @param _header The RF24Network header to be stored in the frame
- * @param _message The 'message' or data.
- * @param _len The size of the 'message' or data.
- *
- * Frames are used internally and by external systems. See RF24NetworkHeader.
- */
+     * **Constructor for Linux platforms** - create a network frame with data
+     * Frames are constructed and handled differently on Arduino/AVR and Linux devices (`#if defined RF24_LINUX`)
+     *
+     * @param _header The RF24Network header to be stored in the frame
+     * @param _message The 'message' or data.
+     * @param _len The size of the 'message' or data.
+     *
+     * Frames are used internally and by external systems. See RF24NetworkHeader.
+     */
 #if defined(RF24_LINUX) || defined(DOXYGEN_FORCED)
     RF24NetworkFrame(RF24NetworkHeader& _header, const void* _message = NULL, uint16_t _len = 0) : header(_header), message_size(_len)
     {
diff --git a/RF24Network_config.h b/RF24Network_config.h
index 33513c8..1903782 100644
--- a/RF24Network_config.h
+++ b/RF24Network_config.h
@@ -43,7 +43,7 @@
     #define RF24NetworkMulticast
 
     /* Saves memory by disabling fragmentation */
-    //#define DISABLE_FRAGMENTATION
+//    #define DISABLE_FRAGMENTATION
 
     /* System defines */
 
@@ -82,14 +82,8 @@
         #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
-     */
-    #define NUM_PIPES 6
-
     /* Debug Options */
-    //#define SERIAL_DEBUG
+    #define SERIAL_DEBUG
     //#define SERIAL_DEBUG_MINIMAL
     //#define SERIAL_DEBUG_ROUTING
     //#define SERIAL_DEBUG_FRAGMENTATION

There is A LOT of dirty hacking going on in the RF24 lib sources. Adding code that is specific to STM32 chips is not as easy as you might think. The HAL libs provided by ST are not the best cross-compatible set of API; the HAL API for STM32F1xx chips is not completely identical as the HAL API for the STM32F4xx chips.

your patch to RF24

diff --git a/RF24.cpp b/RF24.cpp
index 9e5b4a8..a7d8c69 100644
--- a/RF24.cpp
+++ b/RF24.cpp
@@ -12,121 +12,24 @@
 
 /****************************************************************************/
 
-void RF24::csn(bool mode)
+void RF24::csn(GPIO_PinState mode)
 {
-#if defined(RF24_TINY)
-    if (ce_pin != csn_pin) {
-        digitalWrite(csn_pin, mode);
-    }
-    else {
-        if (mode == HIGH) {
-            PORTB |= (1 << PINB2);                         // SCK->CSN HIGH
-            delayMicroseconds(RF24_CSN_SETTLE_HIGH_DELAY); // allow csn to settle.
-        }
-        else {
-            PORTB &= ~(1 << PINB2);                       // SCK->CSN LOW
-            delayMicroseconds(RF24_CSN_SETTLE_LOW_DELAY); // allow csn to settle
-        }
-    }
-    // Return, CSN toggle complete
-    return;
-
-#elif defined(ARDUINO) && !defined(RF24_SPI_TRANSACTIONS)
-    // Minimum ideal SPI bus speed is 2x data rate
-    // If we assume 2Mbs data rate and 16Mhz clock, a
-    // divider of 4 is the minimum we want.
-    // CLK:BUS 8Mhz:2Mhz, 16Mhz:4Mhz, or 20Mhz:5Mhz
-
-    #if !defined(SOFTSPI)
-        // applies to SPI_UART and inherent hardware SPI
-        #if defined(RF24_SPI_PTR)
-    _spi->setBitOrder(MSBFIRST);
-    _spi->setDataMode(SPI_MODE0);
-
-            #if !defined(F_CPU) || F_CPU < 20000000
-    _spi->setClockDivider(SPI_CLOCK_DIV2);
-            #elif F_CPU < 40000000
-    _spi->setClockDivider(SPI_CLOCK_DIV4);
-            #elif F_CPU < 80000000
-    _spi->setClockDivider(SPI_CLOCK_DIV8);
-            #elif F_CPU < 160000000
-    _spi->setClockDivider(SPI_CLOCK_DIV16);
-            #elif F_CPU < 320000000
-    _spi->setClockDivider(SPI_CLOCK_DIV32);
-            #elif F_CPU < 640000000
-    _spi->setClockDivider(SPI_CLOCK_DIV64);
-            #elif F_CPU < 1280000000
-    _spi->setClockDivider(SPI_CLOCK_DIV128);
-            #else // F_CPU >= 1280000000
-                #error "Unsupported CPU frequency. Please set correct SPI divider."
-            #endif // F_CPU to SPI_CLOCK_DIV translation
-
-        #else // !defined(RF24_SPI_PTR)
-    _SPI.setBitOrder(MSBFIRST);
-    _SPI.setDataMode(SPI_MODE0);
-
-            #if !defined(F_CPU) || F_CPU < 20000000
-    _SPI.setClockDivider(SPI_CLOCK_DIV2);
-            #elif F_CPU < 40000000
-    _SPI.setClockDivider(SPI_CLOCK_DIV4);
-            #elif F_CPU < 80000000
-    _SPI.setClockDivider(SPI_CLOCK_DIV8);
-            #elif F_CPU < 160000000
-    _SPI.setClockDivider(SPI_CLOCK_DIV16);
-            #elif F_CPU < 320000000
-    _SPI.setClockDivider(SPI_CLOCK_DIV32);
-            #elif F_CPU < 640000000
-    _SPI.setClockDivider(SPI_CLOCK_DIV64);
-            #elif F_CPU < 1280000000
-    _SPI.setClockDivider(SPI_CLOCK_DIV128);
-            #else // F_CPU >= 1280000000
-                #error "Unsupported CPU frequency. Please set correct SPI divider."
-            #endif // F_CPU to SPI_CLOCK_DIV translation
-        #endif     // !defined(RF24_SPI_PTR)
-    #endif         // !defined(SOFTSPI)
-
-#elif defined(RF24_RPi)
-    if (!mode)
-        _SPI.chipSelect(csn_pin);
-#endif // defined(RF24_RPi)
-
-#if !defined(RF24_LINUX)
-    digitalWrite(csn_pin, mode);
-    delayMicroseconds(csDelay);
-#else
-    static_cast<void>(mode); // ignore -Wunused-parameter
-#endif // !defined(RF24_LINUX)
-}
-
-/****************************************************************************/
-
-void RF24::ce(bool level)
-{
-#ifndef RF24_LINUX
-    //Allow for 3-pin use on ATTiny
-    if (ce_pin != csn_pin) {
-#endif
-        digitalWrite(ce_pin, level);
-#ifndef RF24_LINUX
-    }
-#endif
+	HAL_GPIO_WritePin(NRF24L01P_SPI_CS_PIN_PORT, NRF24L01P_SPI_CS_PIN_NUMBER, mode);
+//    delayMicroseconds(csDelay);
+}
+
+/****************************************************************************/
+
+void RF24::ce(GPIO_PinState level)
+{
+	    HAL_GPIO_WritePin(NRF24L01P_CE_PIN_PORT, NRF24L01P_CE_PIN_NUMBER,level );
 }
 
 /****************************************************************************/
 
 inline void RF24::beginTransaction()
 {
-#if defined(RF24_SPI_TRANSACTIONS)
-    #if defined(RF24_SPI_PTR)
-        #if defined(RF24_RP2)
-    _spi->beginTransaction(spi_speed);
-        #else  // ! defined (RF24_RP2)
-    _spi->beginTransaction(SPISettings(spi_speed, MSBFIRST, SPI_MODE0));
-        #endif // ! defined (RF24_RP2)
-    #else      // !defined(RF24_SPI_PTR)
-    _SPI.beginTransaction(SPISettings(spi_speed, MSBFIRST, SPI_MODE0));
-    #endif     // !defined(RF24_SPI_PTR)
-#endif         // defined (RF24_SPI_TRANSACTIONS)
+
     csn(LOW);
 }
 
@@ -135,201 +38,86 @@ inline void RF24::beginTransaction()
 inline void RF24::endTransaction()
 {
     csn(HIGH);
-#if defined(RF24_SPI_TRANSACTIONS)
-    #if defined(RF24_SPI_PTR)
-    _spi->endTransaction();
-    #else  // !defined(RF24_SPI_PTR)
-    _SPI.endTransaction();
-    #endif // !defined(RF24_SPI_PTR)
-#endif     // defined (RF24_SPI_TRANSACTIONS)
 }
 
 /****************************************************************************/
 
 void RF24::read_register(uint8_t reg, uint8_t* buf, uint8_t len)
 {
-#if defined(RF24_LINUX) || defined(RF24_RP2)
-    beginTransaction(); //configures the spi settings for RPi, locks mutex and setting csn low
-    uint8_t* prx = spi_rxbuff;
-    uint8_t* ptx = spi_txbuff;
-    uint8_t size = static_cast<uint8_t>(len + 1); // Add register value to transmit buffer
-
-    *ptx++ = (R_REGISTER | reg);
-
-    while (len--) {
-        *ptx++ = RF24_NOP; // Dummy operation, just for reading
-    }
-
-    #if defined(RF24_RP2)
-    _spi->transfernb((const uint8_t*)spi_txbuff, spi_rxbuff, size);
-    #else  // !defined (RF24_RP2)
-    _SPI.transfernb(reinterpret_cast<char*>(spi_txbuff), reinterpret_cast<char*>(spi_rxbuff), size);
-    #endif // !defined (RF24_RP2)
-
-    status = *prx++; // status is 1st byte of receive buffer
-
-    // decrement before to skip status byte
-    while (--size) {
-        *buf++ = *prx++;
-    }
-
-    endTransaction(); // unlocks mutex and setting csn high
-
-#else // !defined(RF24_LINUX) && !defined(RF24_RP2)
+    uint8_t command = R_REGISTER | reg;
 
     beginTransaction();
-    #if defined(RF24_SPI_PTR)
-    status = _spi->transfer(R_REGISTER | reg);
-    while (len--) {
-        *buf++ = _spi->transfer(0xFF);
-    }
-
-    #else // !defined(RF24_SPI_PTR)
-    status = _SPI.transfer(R_REGISTER | reg);
-    while (len--) {
-        *buf++ = _SPI.transfer(0xFF);
-    }
-
-    #endif // !defined(RF24_SPI_PTR)
+    HAL_SPI_TransmitReceive(NRF24L01P_SPI, &command, &status, 1, 2000);
+    HAL_SPI_Receive(NRF24L01P_SPI, buf, len, 2000);
     endTransaction();
-#endif     // !defined(RF24_LINUX) && !defined(RF24_RP2)
+//    printf("status= 0x%x\n\r" ,status ) ;
+
 }
 
 /****************************************************************************/
 
 uint8_t RF24::read_register(uint8_t reg)
 {
-    uint8_t result;
-
-#if defined(RF24_LINUX) || defined(RF24_RP2)
-    beginTransaction();
-
-    uint8_t* prx = spi_rxbuff;
-    uint8_t* ptx = spi_txbuff;
-    *ptx++ = (R_REGISTER | reg);
-    *ptx++ = RF24_NOP; // Dummy operation, just for reading
-
-    #if defined(RF24_RP2)
-    _spi->transfernb((const uint8_t*)spi_txbuff, spi_rxbuff, 2);
-    #else  // !defined(RF24_RP2)
-    _SPI.transfernb(reinterpret_cast<char*>(spi_txbuff), reinterpret_cast<char*>(spi_rxbuff), 2);
-    #endif // !defined(RF24_RP2)
-
-    status = *prx;   // status is 1st byte of receive buffer
-    result = *++prx; // result is 2nd byte of receive buffer
-
-    endTransaction();
-#else // !defined(RF24_LINUX) && !defined(RF24_RP2)
-
-    beginTransaction();
-    #if defined(RF24_SPI_PTR)
-    status = _spi->transfer(R_REGISTER | reg);
-    result = _spi->transfer(0xff);
-
-    #else // !defined(RF24_SPI_PTR)
-    status = _SPI.transfer(R_REGISTER | reg);
-    result = _SPI.transfer(0xff);
-
-    #endif // !defined(RF24_SPI_PTR)
-    endTransaction();
-#endif     // !defined(RF24_LINUX) && !defined(RF24_RP2)
-
-    return result;
+    uint8_t buf;
+    read_register(reg, &buf, 1);
+    return buf;
 }
 
 /****************************************************************************/
 
 void RF24::write_register(uint8_t reg, const uint8_t* buf, uint8_t len)
 {
-#if defined(RF24_LINUX) || defined(RF24_RP2)
-    beginTransaction();
-    uint8_t* prx = spi_rxbuff;
-    uint8_t* ptx = spi_txbuff;
-    uint8_t size = static_cast<uint8_t>(len + 1); // Add register value to transmit buffer
+    uint8_t command = W_REGISTER | reg;
+    uint8_t buf_temp[len] = {0x00};
+//    memcpy( (void*)buf_temp , (void*)buf , len );
 
-    *ptx++ = (W_REGISTER | (REGISTER_MASK & reg));
-    while (len--) {
-        *ptx++ = *buf++;
-    }
 
-    #if defined(RF24_RP2)
-    _spi->transfernb((const uint8_t*)spi_txbuff, spi_rxbuff, size);
-    #else  // !defined(RF24_RP2)
-    _SPI.transfernb(reinterpret_cast<char*>(spi_txbuff), reinterpret_cast<char*>(spi_rxbuff), size);
-    #endif // !defined(RF24_RP2)
+//	if (reg == 0x00)
+//	{
+//    uint8_t i = 0 ;
+//	    while (len--) {
+//	        printf("spi_txbuff[%d]=%x  ---->" , i, spi_txbuff[i] );
+//	        printf("&spi_txbuff[%d]=%x \n\r" , i, &spi_txbuff[i] );
+//
+//	        i++;
+//
+//		}
+//    }
+    for (uint8_t index= 0; index <len ; index++)
+    {
+//    	printf("##buf[%d]= 0x%02x \n\r" , index,buf[index] );
 
-    status = *prx; // status is 1st byte of receive buffer
-    endTransaction();
-#else // !defined(RF24_LINUX) && !defined(RF24_RP2)
-
-    beginTransaction();
-    #if defined(RF24_SPI_PTR)
-    status = _spi->transfer(W_REGISTER | reg);
-    while (len--) {
-        _spi->transfer(*buf++);
-    }
-
-    #else // !defined(RF24_SPI_PTR)
-    status = _SPI.transfer(W_REGISTER | reg);
-    while (len--) {
-        _SPI.transfer(*buf++);
+    	buf_temp[index] = buf[index] ;
+//    	printf("buf_temp[%d]= 0x%02x \n\r" , index,buf_temp[index] );
     }
 
-    #endif // !defined(RF24_SPI_PTR)
+    beginTransaction();
+    HAL_SPI_TransmitReceive(NRF24L01P_SPI, &command, &status,1, 2000);
+    HAL_SPI_Transmit(NRF24L01P_SPI, buf_temp, len, 2000);
     endTransaction();
-#endif     // !defined(RF24_LINUX) && !defined(RF24_RP2)
 }
 
 /****************************************************************************/
 
 void RF24::write_register(uint8_t reg, uint8_t value, bool is_cmd_only)
 {
-    if (is_cmd_only) {
-        if (reg != RF24_NOP) { // don't print the get_status() operation
-            IF_SERIAL_DEBUG(printf_P(PSTR("write_register(%02x)\r\n"), reg));
-        }
-        beginTransaction();
-#if defined(RF24_LINUX)
-        status = _SPI.transfer(W_REGISTER | reg);
-#else // !defined(RF24_LINUX) || defined (RF24_RP2)
-    #if defined(RF24_SPI_PTR)
-        status = _spi->transfer(W_REGISTER | reg);
-    #else  // !defined (RF24_SPI_PTR)
-        status = _SPI.transfer(W_REGISTER | reg);
-    #endif // !defined (RF24_SPI_PTR)
-#endif     // !defined(RF24_LINUX) || defined(RF24_RP2)
-        endTransaction();
-    }
-    else {
-        IF_SERIAL_DEBUG(printf_P(PSTR("write_register(%02x,%02x)\r\n"), reg, value));
-#if defined(RF24_LINUX) || defined(RF24_RP2)
-        beginTransaction();
-        uint8_t* prx = spi_rxbuff;
-        uint8_t* ptx = spi_txbuff;
-        *ptx++ = (W_REGISTER | reg);
-        *ptx = value;
-
-    #if defined(RF24_RP2)
-        _spi->transfernb((const uint8_t*)spi_txbuff, spi_rxbuff, 2);
-    #else  // !defined(RF24_RP2)
-        _SPI.transfernb(reinterpret_cast<char*>(spi_txbuff), reinterpret_cast<char*>(spi_rxbuff), 2);
-    #endif // !defined(RF24_RP2)
-
-        status = *prx++; // status is 1st byte of receive buffer
-        endTransaction();
-#else // !defined(RF24_LINUX) && !defined(RF24_RP2)
-
-        beginTransaction();
-    #if defined(RF24_SPI_PTR)
-        status = _spi->transfer(W_REGISTER | reg);
-        _spi->transfer(value);
-    #else  // !defined(RF24_SPI_PTR)
-        status = _SPI.transfer(W_REGISTER | reg);
-        _SPI.transfer(value);
-    #endif // !defined(RF24_SPI_PTR)
-        endTransaction();
-#endif     // !defined(RF24_LINUX) && !defined(RF24_RP2)
-    }
+	//    uint8_t _value[1]= {0};
+	//    _value[0] = value;
+	//
+	//	if (reg == 0x00)
+	//	{
+	//	    printf("_value = %x ------->" , _value[0]);
+	//	    printf("PPPP *_value = %x  #######   " , value );
+	//	}
+	//
+	//
+	//    write_register(reg,_value ,1);
+
+	    uint8_t command = W_REGISTER | reg;
+	    beginTransaction();
+	    HAL_SPI_TransmitReceive(NRF24L01P_SPI, &command, &status,1, 2000);
+	    HAL_SPI_Transmit(NRF24L01P_SPI, &value, 1, 2000);
+	    endTransaction();
 }
 
 /****************************************************************************/
@@ -337,7 +125,7 @@ void RF24::write_register(uint8_t reg, uint8_t value, bool is_cmd_only)
 void RF24::write_payload(const void* buf, uint8_t data_len, const uint8_t writeType)
 {
     const uint8_t* current = reinterpret_cast<const uint8_t*>(buf);
-
+	memset(spi_txbuff, 0, sizeof(spi_txbuff)); // for automatically-allocated arrays
     uint8_t blank_len = !data_len ? 1 : 0;
     if (!dynamic_payloads_enabled) {
         data_len = rf24_min(data_len, payload_size);
@@ -348,16 +136,16 @@ void RF24::write_payload(const void* buf, uint8_t data_len, const uint8_t writeT
     }
 
     //printf("[Writing %u bytes %u blanks]",data_len,blank_len);
-    IF_SERIAL_DEBUG(printf("[Writing %u bytes %u blanks]\n", data_len, blank_len););
+    IF_SERIAL_DEBUG(printf("[Writing %u bytes %u blanks]\r\n", data_len, blank_len););
 
-#if defined(RF24_LINUX) || defined(RF24_RP2)
-    beginTransaction();
-    uint8_t* prx = spi_rxbuff;
+//    beginTransaction();
+//    uint8_t* prx = spi_rxbuff;
     uint8_t* ptx = spi_txbuff;
     uint8_t size;
-    size = static_cast<uint8_t>(data_len + blank_len + 1); // Add register value to transmit buffer
 
-    *ptx++ = writeType;
+    size = static_cast<uint8_t>(data_len + blank_len ); // Add register value to transmit buffer
+
+//    *ptx++ = writeType;
     while (data_len--) {
         *ptx++ = *current++;
     }
@@ -366,47 +154,32 @@ void RF24::write_payload(const void* buf, uint8_t data_len, const uint8_t writeT
         *ptx++ = 0;
     }
 
-    #if defined(RF24_RP2)
-    _spi->transfernb((const uint8_t*)spi_txbuff, spi_rxbuff, size);
-    #else  // !defined(RF24_RP2)
-    _SPI.transfernb(reinterpret_cast<char*>(spi_txbuff), reinterpret_cast<char*>(spi_rxbuff), size);
-    #endif // !defined(RF24_RP2)
+//    for (uint8_t index_t = 0 ; index_t<size ; index_t ++)
+//    {
+//    IF_SERIAL_DEBUG(printf("spi_txbuff[%d] =  0x%02x \r\n", index_t, spi_txbuff[index_t]););
+//    }
+//    uint8_t command = W_TX_PAYLOAD;
 
-    status = *prx; // status is 1st byte of receive buffer
-    endTransaction();
 
-#else // !defined(RF24_LINUX) && !defined(RF24_RP2)
+    write_register(W_TX_PAYLOAD, spi_txbuff, size);
+//    HAL_SPI_Transmit(NRF24L01P_SPI, ptx, size,  2000);
 
-    beginTransaction();
-    #if defined(RF24_SPI_PTR)
-    status = _spi->transfer(writeType);
-    while (data_len--) {
-        _spi->transfer(*current++);
-    }
+//    status = spi_rxbuff[0]; // status is 1st byte of receive buffer
 
-    while (blank_len--) {
-        _spi->transfer(0);
-    }
 
-    #else // !defined(RF24_SPI_PTR)
-    status = _SPI.transfer(writeType);
-    while (data_len--) {
-        _SPI.transfer(*current++);
-    }
+//    IF_SERIAL_DEBUG(printf("write_payload status =  0x%02x \r\n", status););
+
+//    endTransaction();
 
-    while (blank_len--) {
-        _SPI.transfer(0);
-    }
 
-    #endif // !defined(RF24_SPI_PTR)
-    endTransaction();
-#endif     // !defined(RF24_LINUX) && !defined(RF24_RP2)
 }
 
 /****************************************************************************/
 
 void RF24::read_payload(void* buf, uint8_t data_len)
 {
+	memset(spi_rxbuff, 0, sizeof(spi_rxbuff)); // for automatically-allocated arrays
+
     uint8_t* current = reinterpret_cast<uint8_t*>(buf);
 
     uint8_t blank_len = 0;
@@ -418,68 +191,57 @@ void RF24::read_payload(void* buf, uint8_t data_len)
         data_len = rf24_min(data_len, static_cast<uint8_t>(32));
     }
 
-    //printf("[Reading %u bytes %u blanks]",data_len,blank_len);
+//    printf("[Reading %u bytes %u blanks]",data_len,blank_len);
 
     IF_SERIAL_DEBUG(printf("[Reading %u bytes %u blanks]\n", data_len, blank_len););
 
-#if defined(RF24_LINUX) || defined(RF24_RP2)
-    beginTransaction();
+
+//    beginTransaction();
     uint8_t* prx = spi_rxbuff;
-    uint8_t* ptx = spi_txbuff;
+//    uint8_t* ptx = spi_txbuff;
     uint8_t size;
-    size = static_cast<uint8_t>(data_len + blank_len + 1); // Add register value to transmit buffer
+    size = static_cast<uint8_t>(data_len + blank_len); // Add register value to transmit buffer
+
+//    *ptx = R_RX_PAYLOAD;
+//    ptx++;
+//    while (--size) {
+//        *ptx = RF24_NOP;
+//		ptx++;
+//    }
+
+
+//    uint8_t command = R_RX_PAYLOAD;
+    read_register(R_RX_PAYLOAD, spi_rxbuff, size);
+//    HAL_SPI_Receive(NRF24L01P_SPI, prx, size, 2000);
 
-    *ptx++ = R_RX_PAYLOAD;
-    while (--size) {
-        *ptx++ = RF24_NOP;
-    }
 
-    size = static_cast<uint8_t>(data_len + blank_len + 1); // Size has been lost during while, re affect
 
-    #if defined(RF24_RP2)
-    _spi->transfernb((const uint8_t*)spi_txbuff, spi_rxbuff, size);
-    #else  // !defined(RF24_RP2)
-    _SPI.transfernb(reinterpret_cast<char*>(spi_txbuff), reinterpret_cast<char*>(spi_rxbuff), size);
-    #endif // !defined(RF24_RP2)
+//    status =  spi_rxbuff[0]; // status is 1st byte of receive buffer
+
+//	IF_SERIAL_DEBUG(printf("read_payload status =  0x%02x \r\n", status););
 
-    status = *prx++; // 1st byte is status
 
     if (data_len > 0) {
         // Decrement before to skip 1st status byte
         while (--data_len) {
-            *current++ = *prx++;
+        	*current = *prx;
+        	current++ ;
+        	prx++;
         }
 
-        *current = *prx;
+        *current = *spi_rxbuff;
     }
-    endTransaction();
-#else // !defined(RF24_LINUX) && !defined(RF24_RP2)
 
-    beginTransaction();
-    #if defined(RF24_SPI_PTR)
-    status = _spi->transfer(R_RX_PAYLOAD);
-    while (data_len--) {
-        *current++ = _spi->transfer(0xFF);
-    }
+//    for (uint8_t index_t = 0 ; index_t<size ; index_t ++)
+//    {
+//    printf("spi_rxbuff[%d] =  0x%02x \r\n", index_t, spi_rxbuff[index_t]);
+//    }
+//    printf("status =  0x%02x \r\n", status);
+//
 
-    while (blank_len--) {
-        _spi->transfer(0xFF);
-    }
 
-    #else // !defined(RF24_SPI_PTR)
-    status = _SPI.transfer(R_RX_PAYLOAD);
-    while (data_len--) {
-        *current++ = _SPI.transfer(0xFF);
-    }
+//    endTransaction();
 
-    while (blank_len--) {
-        _SPI.transfer(0xff);
-    }
-
-    #endif // !defined(RF24_SPI_PTR)
-    endTransaction();
-
-#endif // !defined(RF24_LINUX) && !defined(RF24_RP2)
 }
 
 /****************************************************************************/
@@ -982,39 +744,6 @@ bool RF24::begin(rf24_gpio_pin_t _cepin, rf24_gpio_pin_t _cspin)
 
 bool RF24::begin(void)
 {
-#if defined(RF24_LINUX)
-    #if defined(RF24_RPi)
-    switch (csn_pin) { // Ensure valid hardware CS pin
-        case 0: break;
-        case 1: break;
-        // Allow BCM2835 enums for RPi
-        case 8: csn_pin = 0; break;
-        case 7: csn_pin = 1; break;
-        case 18: csn_pin = 10; break; // to make it work on SPI1
-        case 17: csn_pin = 11; break;
-        case 16: csn_pin = 12; break;
-        default: csn_pin = 0; break;
-    }
-    #endif // RF24_RPi
-
-    _SPI.begin(csn_pin, spi_speed);
-
-#elif defined(XMEGA_D3)
-    _spi->begin(csn_pin);
-
-#elif defined(RF24_RP2)
-    _spi = new SPI();
-    _spi->begin(PICO_DEFAULT_SPI ? spi1 : spi0);
-
-#else // using an Arduino platform || defined (LITTLEWIRE)
-
-    #if defined(RF24_SPI_PTR)
-    _spi->begin();
-    #else  // !defined(RF24_SPI_PTR)
-    _SPI.begin();
-    #endif // !defined(RF24_SPI_PTR)
-
-#endif // !defined(XMEGA_D3) && !defined(RF24_LINUX)
 
     return _init_pins() && _init_radio();
 }
@@ -1053,11 +782,6 @@ bool RF24::_init_pins()
 
 #else // using an Arduino platform
 
-    // Initialize pins
-    if (ce_pin != csn_pin) {
-        pinMode(ce_pin, OUTPUT);
-        pinMode(csn_pin, OUTPUT);
-    }
 
     ce(LOW);
     csn(HIGH);
@@ -1151,7 +875,7 @@ bool RF24::isChipConnected()
 
 bool RF24::isValid()
 {
-    return ce_pin != RF24_PIN_INVALID && csn_pin != RF24_PIN_INVALID;
+    return true;
 }
 
 /****************************************************************************/
@@ -1530,6 +1254,7 @@ bool RF24::available(void)
 bool RF24::available(uint8_t* pipe_num)
 {
     if (read_register(FIFO_STATUS) & 1) { // if RX FIFO is empty
+//    	printf(" if RX FIFO is empty\n\r");
         return 0;
     }
 
@@ -1548,6 +1273,14 @@ void RF24::read(void* buf, uint8_t len)
     // Fetch the payload
     read_payload(buf, len);
 
+	printf("RF24::read len = %d \n\r " ,len ) ;
+
+	uint8_t* bufbuf = reinterpret_cast<uint8_t*>(buf);
+    for (uint8_t index = 0 ; index < len ; index++)
+    {
+    	printf("RF24::read buf[%d] = 0x%x \n\r " ,index , bufbuf[index] ) ;
+    }
+
     //Clear the only applicable interrupt flags
     write_register(NRF_STATUS, _BV(RX_DR));
 }
@@ -1675,15 +1408,8 @@ void RF24::closeReadingPipe(uint8_t pipe)
 
 void RF24::toggle_features(void)
 {
-    beginTransaction();
-#if defined(RF24_SPI_PTR)
-    status = _spi->transfer(ACTIVATE);
-    _spi->transfer(0x73);
-#else
-    status = _SPI.transfer(ACTIVATE);
-    _SPI.transfer(0x73);
-#endif
-    endTransaction();
+    write_register(ACTIVATE , 0x73 , 0 );
+
 }
 
 /****************************************************************************/
diff --git a/RF24.h b/RF24.h
index 4361b1f..0d88de1 100644
--- a/RF24.h
+++ b/RF24.h
@@ -134,10 +134,8 @@ private:
     rf24_gpio_pin_t ce_pin;  /* "Chip Enable" pin, activates the RX or TX role */
     rf24_gpio_pin_t csn_pin; /* SPI Chip select */
     uint32_t spi_speed;      /* SPI Bus Speed */
-#if defined(RF24_LINUX) || defined(XMEGA_D3) || defined(RF24_RP2)
-    uint8_t spi_rxbuff[32 + 1]; //SPI receive buffer (payload max 32 bytes)
-    uint8_t spi_txbuff[32 + 1]; //SPI transmit buffer (payload max 32 bytes + 1 byte for the command)
-#endif
+    uint8_t spi_rxbuff[32]={0x00}; //SPI receive buffer (payload max 32 bytes)
+    uint8_t spi_txbuff[32]={0x00}; //SPI transmit buffer (payload max 32 bytes + 1 byte for the command)
     uint8_t status;                   /* The status byte returned from every SPI transaction */
     uint8_t payload_size;             /* Fixed size of payloads */
     uint8_t pipe0_reading_address[5]; /* Last address set on pipe 0 for reading. */
@@ -1906,7 +1904,7 @@ private:
      *
      * @param mode HIGH to take this unit off the SPI bus, LOW to put it on
      */
-    void csn(bool mode);
+    void csn(GPIO_PinState mode);
 
     /**
      * Set chip enable
@@ -1914,7 +1912,7 @@ private:
      * @param level HIGH to actively begin transmission or LOW to put in standby.  Please see data sheet
      * for a much more detailed description of this pin.
      */
-    void ce(bool level);
+    void ce(GPIO_PinState level);
 
     /**
      * Write a chunk of data to a register
@@ -2415,4 +2413,4 @@ private:
  * Use `ctrl+c` to quit at any time.
  */
 
-#endif // __RF24_H__
\ No newline at end of file
+#endif // __RF24_H__
diff --git a/RF24_config.h b/RF24_config.h
index 2c836ca..b579ff9 100644
--- a/RF24_config.h
+++ b/RF24_config.h
@@ -21,7 +21,7 @@
 
 /*** USER DEFINES:    ***/
 #define FAILURE_HANDLING
-//#define SERIAL_DEBUG
+#define SERIAL_DEBUG
 //#define MINIMAL
 //#define SPI_UART    // Requires library from https://github.com/TMRh20/Sketches/tree/master/SPI_UART
 //#define SOFTSPI     // Requires library from https://github.com/greiman/DigitalIO
@@ -47,169 +47,57 @@
 /// A sentinel used to control fetching the pipe info in `RF24::available()`.
 #define RF24_NO_FETCH_PIPE 0XFF
 
-//ATXMega
-#if defined(__AVR_ATxmega64D3__) || defined(__AVR_ATxmega128D3__) || defined(__AVR_ATxmega192D3__) || defined(__AVR_ATxmega256D3__) || defined(__AVR_ATxmega384D3__)
-    // In order to be available both in Windows and Linux this should take presence here.
-    #define XMEGA
-    #define XMEGA_D3
-    #include "utility/ATXMegaD3/RF24_arch_config.h"
-
-// RaspberryPi rp2xxx-based devices (e.g. RPi Pico board)
-#elif defined(PICO_BUILD) && !defined(ARDUINO)
-    #include "utility/rp2/RF24_arch_config.h"
-    #define sprintf_P sprintf
-
-#elif (!defined(ARDUINO)) // Any non-arduino device is handled via configure/Makefile
-    // The configure script detects device and copies the correct includes.h file to /utility/includes.h
-    // This behavior can be overridden by calling configure with respective parameters
-    // The includes.h file defines either RF24_RPi, MRAA, LITTLEWIRE or RF24_SPIDEV and includes the correct RF24_arch_config.h file
-    #include "utility/includes.h"
-
-    #ifndef sprintf_P
-        #define sprintf_P sprintf
-    #endif // sprintf_P
-
-//ATTiny
-#elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny2313__) || defined(__AVR_ATtiny4313__) || defined(__AVR_ATtiny861__) || defined(__AVR_ATtinyX5__) || defined(__AVR_ATtinyX4__) || defined(__AVR_ATtinyX313__) || defined(__AVR_ATtinyX61__)
-    #define RF24_TINY
-    #include "utility/ATTiny/RF24_arch_config.h"
-
-#elif defined(LITTLEWIRE) //LittleWire
-    #include "utility/LittleWire/RF24_arch_config.h"
-
-#elif defined(TEENSYDUINO) //Teensy
-    #include "utility/Teensy/RF24_arch_config.h"
-
-#else //Everything else
-    #include <Arduino.h>
-
-    #ifdef NUM_DIGITAL_PINS
-        #if NUM_DIGITAL_PINS < 255
-typedef uint8_t rf24_gpio_pin_t;
-            #define RF24_PIN_INVALID 0xFF
-        #else
-typedef uint16_t rf24_gpio_pin_t;
-            #define RF24_PIN_INVALID 0xFFFF
-        #endif
-    #else
+
+// The configure script detects device and copies the correct includes.h file to /utility/includes.h
+// This behavior can be overridden by calling configure with respective parameters
+// The includes.h file defines either RF24_RPi, MRAA, LITTLEWIRE or RF24_SPIDEV and includes the correct RF24_arch_config.h file
+
+#include "spi.h"
+#include "gpio.h"
+#include <string.h>
+#include <cstdio>
+#include <stdint.h>
+#include <stdio.h>
+
+#ifndef sprintf_P
+	#define sprintf_P sprintf
+#endif // sprintf_P
+
 typedef uint16_t rf24_gpio_pin_t;
         #define RF24_PIN_INVALID 0xFFFF
-    #endif
-
-    #if defined(ARDUINO) && !defined(__arm__) && !defined(__ARDUINO_X86__)
-        #if defined SPI_UART
-            #include <SPI_UART.h>
-            #define _SPI uspi
-        #elif defined(SOFTSPI)
-            // change these pins to your liking
-            //
-            #ifndef SOFT_SPI_MISO_PIN
-                #define SOFT_SPI_MISO_PIN 9
-            #endif // SOFT_SPI_MISO_PIN
-
-            #ifndef SOFT_SPI_MOSI_PIN
-                #define SOFT_SPI_MOSI_PIN 8
-            #endif // SOFT_SPI_MOSI_PIN
-
-            #ifndef SOFT_SPI_SCK_PIN
-                #define SOFT_SPI_SCK_PIN 7
-            #endif // SOFT_SPI_SCK_PIN
-
-const uint8_t SPI_MODE = 0;
-            #define _SPI spi
-
-        #elif defined(ARDUINO_SAM_DUE)
-            #include <SPI.h>
-            #define _SPI SPI
-
-        #else // !defined (SPI_UART) && !defined (SOFTSPI)
-            #include <SPI.h>
-            #define _SPI SPIClass
-            #define RF24_SPI_PTR
-        #endif // !defined (SPI_UART) && !defined (SOFTSPI)
-
-    #else // !defined(ARDUINO) || defined (__arm__) || defined (__ARDUINO_X86__)
-        // Define _BV for non-Arduino platforms and for Arduino DUE
-        #include <stdint.h>
-        #include <stdio.h>
-        #include <string.h>
-
-        #if defined(__arm__) || defined(__ARDUINO_X86__)
-            #if defined(__arm__) && defined(SPI_UART)
-                #include <SPI_UART.h>
-                #define _SPI uspi
-
-            #else // !defined (__arm__) || !defined (SPI_UART)
-                #include <SPI.h>
-                #define _SPI SPIClass
-                #define RF24_SPI_PTR
-
-            #endif // !defined (__arm__) || !defined (SPI_UART)
-        #elif !defined(__arm__) && !defined(__ARDUINO_X86__)
-// fallback to unofficially supported Hardware (courtesy of ManiacBug)
-extern HardwareSPI SPI;
-            #define _SPI HardwareSPI
-            #define RF24_SPI_PTR
-
-        #endif // !defined(__arm__) && !defined (__ARDUINO_X86__)
-
-        #ifndef _BV
-            #define _BV(x) (1 << (x))
-        #endif
-    #endif // defined (ARDUINO) && !defined (__arm__) && !defined (__ARDUINO_X86__)
-
-    #ifdef SERIAL_DEBUG
-        #define IF_SERIAL_DEBUG(x) ({ x; })
-    #else
-        #define IF_SERIAL_DEBUG(x)
-        #if defined(RF24_TINY)
-            #define printf_P(...)
-        #endif // defined(RF24_TINY)
-
-    #endif // SERIAL_DEBUG
-
-    #if defined(__ARDUINO_X86__)
-        #define printf_P printf
-        #define _BV(bit) (1 << (bit))
-
-    #endif // defined (__ARDUINO_X86__)
-
-    // Progmem is Arduino-specific
-    #if defined(ARDUINO_ARCH_ESP8266) || defined(ESP32) || (defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_ARCH_MBED))
-        #include <pgmspace.h>
-        #define PRIPSTR "%s"
-        #ifndef pgm_read_ptr
-            #define pgm_read_ptr(p) (*(void* const*)(p))
-        #endif
-        // Serial.printf() is no longer defined in the unifying Arduino/ArduinoCore-API repo
-        // Serial.printf() is defined if using the arduino-pico/esp32/8266 repo
-        #if defined(ARDUINO_ARCH_ESP32) // do not `undef` when using the espressif SDK only
-            #undef printf_P             // needed for ESP32 core
-        #endif
-        #define printf_P Serial.printf
-    #elif defined(ARDUINO) && !defined(ESP_PLATFORM) && !defined(__arm__) && !defined(__ARDUINO_X86__) || defined(XMEGA)
-        #include <avr/pgmspace.h>
-        #define PRIPSTR "%S"
-
-    #else                     // !defined (ARDUINO) || defined (ESP_PLATFORM) || defined (__arm__) || defined (__ARDUINO_X86__) && !defined (XMEGA)
-        #if !defined(ARDUINO) // This doesn't work on Arduino DUE
-typedef char const char;
-        #else                 // Fill in pgm_read_byte that is used
-            #if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_SAM_DUE)
-                #include <avr/pgmspace.h> // added to ArduinoCore-sam (Due core) in 2013
-            #endif
-
-            // Since the official arduino/ArduinoCore-samd repo switched to a unified API in 2016,
-            // Serial.printf() is no longer defined in the unifying Arduino/ArduinoCore-API repo
-            #if defined(ARDUINO_ARCH_SAMD) && defined(ARDUINO_SAMD_ADAFRUIT)
-                // it is defined if using the adafruit/ArduinoCore-samd repo
-                #define printf_P Serial.printf
-            #endif // defined (ARDUINO_ARCH_SAMD)
-
-            #ifndef pgm_read_byte
-                #define pgm_read_byte(addr) (*(const unsigned char*)(addr))
-            #endif
-        #endif // !defined (ARDUINO)
+
+
+
+#define NRF24L01P_SPI (&hspi1)
+
+#ifndef _BV
+	#define _BV(x) (1 << (x))
+#endif
+
+#ifdef SERIAL_DEBUG
+	#define IF_SERIAL_DEBUG(x) ({ x; })
+#else
+	#define IF_SERIAL_DEBUG(x)
+#endif // SERIAL_DEBUG
+
+#define PRIPSTR "%s"
+#define pgm_read_ptr(p) (*(void* const*)(p))
+#define pgm_read_byte(p) (*(const unsigned char*)(p))
+#define printf_P printf
+#define LOW                      GPIO_PIN_RESET
+#define HIGH                     GPIO_PIN_SET
+#define delay(milisec)           HAL_Delay(milisec)
+#define delayMicroseconds(usec)  delay_us(usec)
+#define millis()                 HAL_GetTick()
+#define NRF24L01P_SPI_CS_PIN_PORT         SPI1_CSN_GPIO_Port
+#define NRF24L01P_SPI_CS_PIN_NUMBER       SPI1_CSN_Pin
+
+#define NRF24L01P_CE_PIN_PORT             SPI1_CE_GPIO_Port
+#define NRF24L01P_CE_PIN_NUMBER           SPI1_CE_Pin
+
+#define NRF24L01P_IRQ_PIN_PORT            SPI1_IRQ_GPIO_Port
+#define NRF24L01P_IRQ_PIN_NUMBER          SPI1_IRQ_Pin
+
 
         #ifndef prog_uint16_t
 typedef uint16_t prog_uint16_t;
@@ -229,19 +117,94 @@ typedef uint16_t prog_uint16_t;
         #ifndef pgm_read_word
             #define pgm_read_word(p) (*(const unsigned short*)(p))
         #endif
-        #if !defined pgm_read_ptr || defined ARDUINO_ARCH_MBED
-            #define pgm_read_ptr(p) (*(void* const*)(p))
-        #endif
-        #ifndef PRIPSTR
-            #define PRIPSTR "%s"
-        #endif
-
-    #endif // !defined (ARDUINO) || defined (ESP_PLATFORM) || defined (__arm__) || defined (__ARDUINO_X86__) && !defined (XMEGA)
 
-#endif //Everything else
 
-#if defined(SPI_HAS_TRANSACTION) && !defined(SPI_UART) && !defined(SOFTSPI)
-    #define RF24_SPI_TRANSACTIONS
-#endif // defined (SPI_HAS_TRANSACTION) && !defined (SPI_UART) && !defined (SOFTSPI)
 
+//
+///*
+// Copyright (C)
+//    2011            J. Coliz <[email protected]>
+//    2015-2019       TMRh20
+//    2015            spaniakos <[email protected]>
+//    2015            nerdralph
+//    2015            zador-blood-stained
+//    2016            akatran
+//    2017-2019       Avamander <[email protected]>
+//    2019            IkpeohaGodson
+//    2021            2bndy5
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// version 2 as published by the Free Software Foundation.
+//*/
+//
+//#ifndef __RF24_CONFIG_H__
+//#define __RF24_CONFIG_H__
+//
+//#ifdef __cplusplus
+//extern "C" {
+//#endif
+//
+//#include "spi.h"
+//#include "gpio.h"
+//#include <string.h>
+//#include <cstdio>
+//
+//#define _BV(x) (1 << (x))
+//
+///* User Configurations */
+//#define NRF24L01P_SPI                     (&hspi1)
+//
+//#define NRF24L01P_SPI_CS_PIN_PORT         SPI1_CSN_GPIO_Port
+//#define NRF24L01P_SPI_CS_PIN_NUMBER       SPI1_CSN_Pin
+//
+//#define NRF24L01P_CE_PIN_PORT             SPI1_CE_GPIO_Port
+//#define NRF24L01P_CE_PIN_NUMBER           SPI1_CE_Pin
+//
+//#define NRF24L01P_IRQ_PIN_PORT            SPI1_IRQ_GPIO_Port
+//#define NRF24L01P_IRQ_PIN_NUMBER          SPI1_IRQ_Pin
+//
+///*** USER DEFINES:    ***/
+//#define FAILURE_HANDLING
+//#define RF24_STM32
+//#define SERIAL_DEBUG
+////#define MINIMAL
+//
+//#define RF24_POWERUP_DELAY 5000
+//
+///**********************/
+//#define rf24_max(a, b) (a > b ? a : b)
+//#define rf24_min(a, b) (a < b ? a : b)
+//
+//// #define sprintf_P sprintf
+//
+//#define _BV(x) (1 << (x))
+//
+//#ifdef SERIAL_DEBUG
+//    #define IF_SERIAL_DEBUG(x) ({ x; })
+//#endif
+//
+//typedef uint16_t prog_uint16_t;
+//typedef uint16_t rf24_gpio_pin_t;
+//#define PSTR(x)  (x)
+//#define pgm_read_ptr(p) (*(void* const*)(p))
+//#define sprintf_P sprintf
+//#define printf_P printf
+//#define strlen_P strlen
+//#define PROGMEM
+//#define pgm_read_word(p) (*(const unsigned short*)(p))
+//#define PRIPSTR          "%s"
+//#define pgm_read_byte(p) (*(const unsigned char*)(p))
+//
+//// Function, constant map as a result of migrating from Arduino
+//#define LOW                      GPIO_PIN_RESET
+//#define HIGH                     GPIO_PIN_SET
+//#define delay(milisec)           HAL_Delay(milisec)
+//#define delayMicroseconds(usec)  delay_us(usec)
+//#define millis()                 HAL_GetTick()
+//
+//#ifdef __cplusplus
+//}
+//#endif
+//
 #endif // __RF24_CONFIG_H__

What you've basically done is add support for STM32Cube IDE specific to your board. See nRF24/RF24#872 for the reason why we stopped developing a solution toward STM32Cube support.


I remembered a very important thing that I added to RPI...
...
time.sleep(sys.float_info.min)

I don't think adding time.sleep(sys.float_info.min) to the pyrf24 examples would be a meaningful contribution.

>>> import sys
>>> sys.float_info.min  # for Windows 11
2.2250738585072014e-308
>>> help(sys.float_info)
 |  float_info(iterable=(), /)
 |
 |  sys.float_info
 |
 |  A named tuple holding information about the float type. It contains low level
 |  information about the precision and internal representation. Please study
 |  your system's :file:`float.h` for more information.

Given that sys.float_info is platform specific, I don't see how waiting for ~2 seconds fixes anything. IMHO, adding delays to buggy source code is the sign of a beginner trying to hide an unknown problem.

@naty6458
Copy link

naty6458 commented Mar 3, 2024

Hi, thanks for the reply.
That's right, I'm talking about STM CUBE and not Arduino IDE.
The reason I downloaded the

bool RF24::isValid()
{
     return ce_pin != RF24_PIN_INVALID && csn_pin != RF24_PIN_INVALID;
}

Because it is not relevant when you use STM CUBE.
You configure the SPI pins through the STM interface.
Therefore there is no reason to correct the ID of the pins.

Regarding the RPI delay, I added the smallest value possible in FLOAT so that there is as fast an update to the network as possible.

It is clear to me that in order to release a version that is suitable for all types of users, there is still a lot of work to be done. But the files I shared can be a nice start to support STM CUBE.
And by the way, this can be for any STM board, not specific to mine. All you have to do is set the pins in RF24_config.h

Given that sys.float_info is platform specific, I don't see how waiting for ~2 seconds fixes anything. IMHO, adding delays to buggy source code is the sign of a beginner trying to hide an unknown problem.

It's not 2 seconds, it's 2 seconds to the power of e minus 308. This is the smallest number of the Python on the RPI
The point I was trying to convey is that a small delay should be put there.
If not it simply does not work or works really badly, at least in my case of the RPI3

@2bndy5
Copy link
Member

2bndy5 commented Mar 3, 2024

@TMRh20 I think we need to close this 6 year old issue. This is the second time it was hijacked by someone with an unrelated problem. Now it is just a misleading dead end for anyone trying troubleshoot their specific problem. If someone comes across with a seemingly similar problem, then they can open a new issue and just reference it using "#137".

@2bndy5 2bndy5 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 3, 2024
@2bndy5
Copy link
Member

2bndy5 commented Mar 3, 2024

@naty6458 I'm glad you got it working you you.

But the files I shared can be a nice start to support STM CUBE

If you would like to contribute towards STM Cube IDE support then please use nRF24/RF24#872. We already have a branch setup to experiment with STM Cube IDE support.

Because it is not relevant when you use STM CUBE.
You configure the SPI pins through the STM interface.
Therefore there is no reason to correct the ID of the pins.

Maybe this makes sense to you because your board doesn't require you to use jumper cables. But radio.isValid() was added as a convenience for those who spent too much time troubleshooting software when all they did was connect the wrong pins with jumper cables.

The point I was trying to convey is that a small delay should be put there.
If not it simply does not work or works really badly, at least in my case of the RPI3

I stand by the fact that adding a delay only hides a real problem, which might have been fixed (this morning) in nRF24/RF24#952 but not released in pyRF24 yet.

@naty6458
Copy link

naty6458 commented Mar 3, 2024

Hey ,

If you would like to contribute towards STM Cube IDE support then please use nRF24/RF24#872. We already have a branch setup to experiment with STM Cube IDE support.

Thanks for sharing, I didn't know there was such a branch for STM CUBE.
It looks much more professional than what I did. I'll try it in a hurry.

Maybe this makes sense to you because your board doesn't require you to use jumper cables. But radio.isValid() was added as a convenience for those who spent too much time troubleshooting software when all they did was connect the wrong pins with jumper cables.

You are absolutely right about this.

I stand by the fact that adding a delay only hides a real problem, which might have been fixed (this morning) in nRF24/RF24#952 but not released in pyRF24 yet.

I can't wait for this version to be released.

Thank you very much for the guidance and consideration.

@2bndy5
Copy link
Member

2bndy5 commented Mar 4, 2024

I can't wait for this version to be released.

You can test it out by installing pyrf24 from source, but you have to update the RF24 submodule first. There's also some preliminary support for RPi5 in RF24 master branch.

cd pyRF24/RF24
git checkout master
git pull
cd ../
pip install -v .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants