unlogic stop

hi all

i have written a simple program to exchange array of bytes between two arduinos using a couple of NRF24L01

it works fine ,but when i use a hash function(sha256) the transfer stops without a logical explaination ,though the RAM usage is only 33%

transmitter code

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>
#include "sha256.h"

/*
This sketch sends a string to a corresponding Arduino
with nrf24 attached.  It appends a specific value 
(2 in this case) to the end to signify the end of the
message.
*/
#define WHICH_NODE 1

const uint64_t wAddress[] = {0x7878787878LL, 0xB3B4B5B6F1LL, 0xB3B4B5B6CDLL, 0xB3B4B5B6A3LL, 0xB3B4B5B60FLL, 0xB3B4B5B605LL};

 const uint64_t PTXpipe = wAddress[WHICH_NODE];   // Pulls the address from the above array for this node's pipe
  

RF24 radio(8,10);

byte arr[33] ;
 uint8_t* hash;
 
void printHash(uint8_t* hash) {
  
  for (int i=0; i<32; i++) {
     //(String)hash = (String) ID + (String) hash;
    Serial.print("0123456789abcdef"[hash[i]>>4]);
    Serial.print("0123456789abcdef"[hash[i]&0xf]);

  }
  Serial.println();
}

void setup(void)
{
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(PTXpipe); 
  radio.stopListening(); }
  
void loop()
{
  byte arr[33] ;
  char xx[21];
String str ="12345678901234567890";
str.toCharArray(xx, 21);
 

Sha256.initHmac((uint8_t*)xx,21);
//Serial.println(xx);
  Sha256.print("node 1");
 // delay(10);
 hash=Sha256.resultHmac();
  
 
for( int j=0;j<32;j++)
{arr[j]=hash[j];
 Serial.print(arr[j],HEX);
  }

  delay(10);



arr[32]='\0';
//Serial.println();
    
 
    radio.write(arr,33);
Serial.println(arr);

 
 
}

Receiver code

#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>
#include <SPI.h>

/*
This sketch receives strings from sending unit via nrf24 
and prints them out via serial.  The sketch waits until
it receives a specific value (2 in this case), then it 
prints the complete message and clears the message buffer.
*/
byte pipeNum = 0;


RF24 radio(8,10);
 const uint64_t rAddress[] = {0x7878787878LL, 0xB3B4B5B6F1LL, 0xB3B4B5B6CDLL, 0xB3B4B5B6A3LL, 0xB3B4B5B60FLL, 0xB3B4B5B605LL };
int lastmsg = 1;

char theMessage[33] = "";

void setup(void){
  Serial.begin(9600);
  radio.begin();
   radio.openReadingPipe(2,rAddress[2]);
  radio.openReadingPipe(1,rAddress[1]);

  radio.startListening();
}

void loop(void)
{
       
  while (radio.available(&pipeNum))
  {
      radio.read( theMessage , 33 );
      Serial.print("received : ");
      Serial.print(theMessage);
      Serial.print(" from ");
      Serial.print(pipeNum);
      Serial.println();
      
}}

when i tried to send another array of bytes other than the one in the hash function it works only when i restart the transmitter’s board

what is the cause of that?

thanks in advance for your help

    radio.write(arr,33);
   radio.read( theMessage , 33 );

What is the maximum data size that can be transferred?

you are right Whandall
i decreased the size to 32 bytes and the receiver received a message
but now when i print the characters it is unreadable

received : ¢.&ÍbƒK�CôØqÐcµÞv�3–ÑwNíÛØ’·?‘ from 1
received : ¢.&ÍbƒK�CôØqÐcµÞv�3–ÑwNíÛØ’·?‘ from 1

I'm quite shure it is what you sent.

yes you are right this time too

i made a loop to print the received message in hex

 for(int x=0;x<32;x++)
      Serial.print(theMessage[x],HEX);

So your problem is solved now?

yes thx a lot for your contribution