Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arduino 如何让接收方知道发送方已收到确认记录包?_Arduino_Radio - Fatal编程技术网

Arduino 如何让接收方知道发送方已收到确认记录包?

Arduino 如何让接收方知道发送方已收到确认记录包?,arduino,radio,Arduino,Radio,我使用库连接了两个nrf24l01+模块。我想实现以下场景: 1. A sends a payload packet to B 2. B receives the payload packet 3. B responds with an ACK packet 4. A receives the ACK packet 5. A sends an ACK packet to B 6. B receives the ACK packet 现在,我只需在发送方上使用以下代码,就可以实现到步骤4: bo

我使用库连接了两个nrf24l01+模块。我想实现以下场景:

1. A sends a payload packet to B
2. B receives the payload packet
3. B responds with an ACK packet
4. A receives the ACK packet
5. A sends an ACK packet to B
6. B receives the ACK packet
现在,我只需在发送方上使用以下代码,就可以实现到步骤4:

bool delivered = radio.read(&message, sizeof(Message));

有没有一种方法可以在不改变角色和编写大量额外代码的情况下实现其他步骤?或者库提供了一些简单的方法来实现这一点吗?

您可以通过输入有效负载来发送步骤5中描述的ACK。可能有必要用一个小标题来包装您的有效负载。此标头可用于指示它是数据或第二次确认

#define MAX_PAYLOAD_DATA_SIZE   (10u)

typedef enum packet_type{
  DATA_PACKET, 
  ACK_PACKET,

  PACKET_MAX
}packet_type_t;

typedef struct payload{
  packet_type_t packetType;
  uint8_t len;
  uint8_t data[MAX_PAYLOAD_DATA_SIZE];
}payload_t;