亲爱的楼主,是这样的,我手上已有了uno,和nrf24l01,各一对,所以想参照大神的代码做个简单的实验先试一下,但是发现总是不行。
发送端我自己将代码做了删减,接收端没有删减,这里贴出发送端代码,请大神看下有什么问题。
[AppleScript] 纯文本查看 复制代码 #include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
#include <EtherCard.h>
// Address of our node
const uint16_t this_node = 0;
// Address of the other node
const uint16_t other_node = 1;
struct payload_t
{
uint32_t ms;
uint32_t data;
char sendchar[20];
};
//NRF24l01 send data
RF24 radioSend(9,10);
RF24Network networkSend(radioSend);
char updateData[17]={0};
uint16_t sendChannel=1;
uint32_t sendCount=0;
byte Ethernet::buffer[400];
void setup(void)
{
Serial.begin(9600);
Serial.println("Enc28j60_RF24Network/TX");
SPI.begin();
radioSend.begin();
networkSend.begin(/*channel*/ sendChannel, /*node address*/ other_node);
}
void loop(void)
{
networkSend.begin(/*channel*/ sendChannel, /*node address*/ other_node);
networkSend.update();
Serial.println("");
Serial.print("Sending...");
if(sendCount>1000000) sendCount=0;
payload_t payload = { sendChannel, sendCount++, "{ck000000000000}" };//millis()
RF24NetworkHeader header(/*to node*/ this_node);
Serial.println(sendChannel);
bool ok = networkSend.write(header,&payload,sizeof(payload));
if (ok)
{
Serial.println("ok.");
char front[10]={0};
memcpy(front,"this_is_send_inf",9);
sprintf(updateData,"%supdate}",front);
Serial.println(updateData);
}
else
{
Serial.println("failed.");
}
delay(1000);
}
|