发帖
12 0 0

Ra-01收发切换

qqneinei
注册会员

1

主题

6

回帖

66

积分

注册会员

积分
66
Ra-01S/01SH系列 360 12 4 天前
Ra-01可以先收数据,收到数据后再把数据发出去吗?网上说切换DIO0的电平实现切换,能具体点吗?我这边试了后还是只能一个芯片收,另一个发,没办法在一块芯片上实现收发
──── 0人觉得很赞 ────

使用道具 举报

通过状态识别切换,发送数据出发TXDONE以后即可进入接收模式接收数据,参考pingpong用例使用方法
4 天前
RitaChen 发表于 2025-3-21 08:44
通过状态识别切换,发送数据出发TXDONE以后即可进入接收模式接收数据,参考pingpong用例使用方法 ...

请问下这个“pingpong用例”能给个链接吗?我在官网没有找到
	while (1)
	{
		switch (State)
		{
		case RX:
			if (isMaster == true)
			{
				if (BufferSize > 0)
				{
					if (strncmp((const char *)Buffer, (const char *)PongMsg, 4) == 0)
					{
						printf("Received: PONG\r\n");

						// Send the next PING frame
						Buffer[0] = 'P';
						Buffer[1] = 'I';
						Buffer[2] = 'N';
						Buffer[3] = 'G';
						// We fill the buffer with numbers for the payload
						for (i = 4; i < BufferSize; i++)
						{
							Buffer[i] = i - 4;
						}
						delay_ms(10);
						printf("Sent: PING\r\n");
#ifdef REINIT_FLAG
						Radio_TX_Resetting();
#endif
						Radio.Send(Buffer, BufferSize);
					}
					else if (strncmp((const char *)Buffer, (const char *)PingMsg, 4) == 0)
					{ // A master already exists then become a slave
						isMaster = false;
#ifdef REINIT_FLAG
						Radio_RX_Resetting();
#endif
						Radio.Rx(LORA_RX_TIMEOUT_VALUE);
					}
					else // valid reception but neither a PING or a PONG message
					{	 // Set device as master ans start again
						isMaster = true;
#ifdef REINIT_FLAG
						Radio_RX_Resetting();
#endif
						Radio.Rx(LORA_RX_TIMEOUT_VALUE);
					}
				}
			}
			else
			{
				if (BufferSize > 0)
				{
					if (strncmp((const char *)Buffer, (const char *)PingMsg, 4) == 0)
					{
						printf("Received: PING\r\n");

						// Send the reply to the PONG string
						Buffer[0] = 'P';
						Buffer[1] = 'O';
						Buffer[2] = 'N';
						Buffer[3] = 'G';
						// We fill the buffer with numbers for the payload
						for (i = 4; i < BufferSize; i++)
						{
							Buffer[i] = i - 4;
						}
						delay_ms(10);
#ifdef REINIT_FLAG
						Radio_TX_Resetting();
#endif
						Radio.Send(Buffer, BufferSize);
						printf("Sent: PONG\r\n");
					}
					else // valid reception but not a PING as expected
					{	 // Set device as master and start again
						isMaster = true;
#ifdef REINIT_FLAG
						Radio_RX_Resetting();
#endif
						Radio.Rx(LORA_RX_TIMEOUT_VALUE);
					}
				}
			}
			State = LOWPOWER;
			break;
		case TX:
#ifdef REINIT_FLAG
			Radio_RX_Resetting();
#endif
			Radio.Rx(LORA_RX_TIMEOUT_VALUE);
			State = LOWPOWER;
			break;
		case RX_TIMEOUT:
		case RX_ERROR:
			if (isMaster == true)
			{
				// Send the next PING frame
				Buffer[0] = 'P';
				Buffer[1] = 'I';
				Buffer[2] = 'N';
				Buffer[3] = 'G';
				for (i = 4; i < BufferSize; i++)
				{
					Buffer[i] = i - 4;
				}
				random = (rand() + 1) % 90;
				delay_ms(random);
#ifdef REINIT_FLAG
				Radio_TX_Resetting();
#endif
				Radio.Send(Buffer, BufferSize);
				printf("Sent: PING\r\n");
			}
			else
			{
#ifdef REINIT_FLAG
				Radio_RX_Resetting();
#endif
				Radio.Rx(LORA_RX_TIMEOUT_VALUE);
			}
			State = LOWPOWER;
			break;
		case TX_TIMEOUT:
#ifdef REINIT_FLAG
			Radio_RX_Resetting();
#endif
			Radio.Rx(LORA_RX_TIMEOUT_VALUE);
			State = LOWPOWER;
			break;
		case LOWPOWER:
		default:
			// Set low power
			break;
		}

		// Process Radio IRQ
		Radio.IrqProcess();
	}
4 天前
RitaChen 发表于 2025-3-21 09:06
while (1)
        {
                switch (State)

谢谢你,老哥
qqneinei 发表于 2025-3-21 08:59
请问下这个“pingpong用例”能给个链接吗?我在官网没有找到

上传的附件: PingPong.c (7.55 KB, 下载次数: 1)

4 天前

老哥,请问下它这个DIO0是接收进入中断还是发送进入中断啊?我看官方Demo上面说发送进入中断,但是实际却是接收进入中断
qqneinei 发表于 2025-3-21 09:15
老哥,请问下它这个DIO0是接收进入中断还是发送进入中断啊?我看官方Demo上面说发送进入中断,但是实际却 ...

dio0是多种终端,触发中断之后还要去查状态码,确定触发中断的是那个条件,移植我们代码。用我刚刚上传的代码附件
4 天前
爱笑 发表于 2025-3-21 09:32
dio0是多种终端,触发中断之后还要去查状态码,确定触发中断的是那个条件,移植我们代码。用我刚刚上传的 ...

打开后中文显示乱码,换了UTF-8和GB2312都不行
4 天前
爱笑 发表于 2025-3-21 09:32
dio0是多种终端,触发中断之后还要去查状态码,确定触发中断的是那个条件,移植我们代码。用我刚刚上传的 ...

能给个完整的工程吗??
您需要登录后才可以回帖 立即登录
高级模式
12下一页
统计信息
  • 会员数: 28167 个
  • 话题数: 39945 篇