Grag38:
can you try with :
return network.write(header,myString,sizeof(myString));
Nope. I obtain:
16000: APP Sending 16000 to 00...
String hello
16003: APP Send ok
16006: APP Received 25960 from 00
But I've surely identified another problem. The receiving funtion saves the result to a long int. This is not good.
original send function:
/**
* Send a 'T' message, the current time
*/
bool send_T(uint16_t to)
{
RF24NetworkHeader header(/*to node*/ to, /*type*/ 'T' /*Time*/);
// The 'T' message that we send is just a ulong, containing the time
unsigned long message = millis();
printf_P(PSTR("---------------------------------\n\r"));
printf_P(PSTR("%lu: APP Sending %lu to 0%o...\n\r"),millis(),message,to);
return network.write(header,&message,sizeof(unsigned long));
}
original receiving function:
/**
* Handle a 'T' message
*
* Add the node to the list of active nodes
*/
void handle_T(RF24NetworkHeader& header)
{
// The 'T' message is just a ulong, containing the time
unsigned long message;
network.read(header,&message,sizeof(unsigned long));
printf_P(PSTR("%lu: APP Received %lu from 0%o\n\r"),millis(),message,header.from_node);
// If this message is from ourselves or the base, don't bother adding it to the active nodes.
if ( header.from_node != this_node || header.from_node > 00 )
add_node(header.from_node);
}
The 'handle_T' must be corrected as well.
My modified version:
send:
/**
* Send a 'T' message, the current time
*/
bool send_T(uint16_t to)
{
RF24NetworkHeader header(/*to node*/ to, /*type*/ 'T' /*Time*/);
// The 'T' message that we send is just a ulong, containing the time
unsigned long message = millis();
printf_P(PSTR("---------------------------------\n\r"));
printf_P(PSTR("%lu: APP Sending %lu to 0%o...\n\r"),millis(),message,to);
// simo
myString = "hello";
printf_P(PSTR("Stringa %s\n\r"), myString);
return network.write(header,myString,sizeof(myString));
//return network.write(header,&message,sizeof(unsigned long));
}
receive:
void handle_T(RF24NetworkHeader& header)
{
// The 'T' message is just a ulong, containing the time
unsigned long message;
//network.read(header,&message,sizeof(unsigned long));
//printf_P(PSTR("%lu: APP Received %lu from 0%o\n\r"),millis(),message,header.from_node);
//simo
char *receivedString;
network.read(header,receivedString,sizeof(receivedString));
printf_P(PSTR("%lu: APP Received %s from 0%o\n\r"),millis(),receivedString,header.from_node);
// If this message is from ourselves or the base, don't bother adding it to the active nodes.
if ( header.from_node != this_node || header.from_node > 00 )
add_node(header.from_node);
}
Result:
2000: APP Sending 2000 to 00...
Stringa hello
2003: APP Send ok
12829108005: APP Received from 00
---------------------------------
4000: APP Sending 4000 to 00...
Stringa hello
4003: APP Send ok
12829108205: APP Received from 00
Now the receiving variable is empty?