diff --git a/board/TencentOS_tiny_EVB_LX/BSP/LoRaWAN/lora_demo.c b/board/TencentOS_tiny_EVB_LX/BSP/LoRaWAN/lora_demo.c index 158d6e50..cf677da6 100644 --- a/board/TencentOS_tiny_EVB_LX/BSP/LoRaWAN/lora_demo.c +++ b/board/TencentOS_tiny_EVB_LX/BSP/LoRaWAN/lora_demo.c @@ -95,7 +95,8 @@ uint8_t pool[DATA_CNT]; void application_entry(void *arg) { int i = 0; - + int ret = 0; + int send_failed_count = 0; rhf76_lora_init(HAL_UART_PORT_1); tos_lora_module_recvcb_register(recv_callback); @@ -113,7 +114,20 @@ void application_entry(void *arg) } printf("\n\n"); - tos_lora_module_send(&dev_data.data, mail_size); + ret = tos_lora_module_send(&dev_data.data, mail_size); + if (ret < 0 ) + { + printf("LoRa Send data faild! count is %d\r\n",send_failed_count); + send_failed_count++; + if (send_failed_count > 10) + { + eclic_system_reset();// when lora send faied more than 10 times , cpu reset to reconnect. + } + } + else + { + send_failed_count = 0; + } } } diff --git a/board/TencentOS_tiny_EVB_MX_Plus/BSP/LoRaWAN/lora_demo.c b/board/TencentOS_tiny_EVB_MX_Plus/BSP/LoRaWAN/lora_demo.c index 77998e71..d88f2fce 100644 --- a/board/TencentOS_tiny_EVB_MX_Plus/BSP/LoRaWAN/lora_demo.c +++ b/board/TencentOS_tiny_EVB_MX_Plus/BSP/LoRaWAN/lora_demo.c @@ -95,7 +95,8 @@ uint8_t pool[DATA_CNT]; void application_entry(void *arg) { int i = 0; - + int ret = 0; + int send_failed_count = 0; rhf76_lora_init(HAL_UART_PORT_0); tos_lora_module_recvcb_register(recv_callback); @@ -113,7 +114,20 @@ void application_entry(void *arg) } printf("\n\n"); - tos_lora_module_send(&dev_data.data, mail_size); + ret = tos_lora_module_send(&dev_data.data, mail_size); + if (ret < 0 ) + { + printf("LoRa Send data faild!, count is %d\r\n",send_failed_count); + send_failed_count++; + if (send_failed_count > 10) + { + NVIC_SystemReset();// when lora send faied more than 10 times , cpu reset to reconnect. + } + } + else + { + send_failed_count = 0; + } } } diff --git a/devices/rhf76_lora/RHF76.c b/devices/rhf76_lora/RHF76.c index 567d8cb8..85eef1e7 100644 --- a/devices/rhf76_lora/RHF76.c +++ b/devices/rhf76_lora/RHF76.c @@ -526,12 +526,12 @@ static int rhf76_send(const void *buf, size_t len) snprintf(cmd, sizeof(cmd), RHF76_ATCMD_FMT_SEND_CMSGHEX, str_buf); cmd[sizeof(cmd) - 1] = '\0'; tos_mmheap_free(str_buf); - tos_at_echo_create(&echo, NULL, 0, "+CMSG: ACK Received"); + tos_at_echo_create(&echo, NULL, 0, "+CMSGHEX: ACK Received"); tos_at_cmd_exec(&echo, 6000, cmd); if (echo.status == AT_ECHO_STATUS_OK || echo.status == AT_ECHO_STATUS_EXPECT) { - return -1; + return len; } - return len; + return -1; } static int rhf76_send_unconfirmed(const void *buf, size_t len) @@ -552,9 +552,9 @@ static int rhf76_send_unconfirmed(const void *buf, size_t len) tos_at_echo_create(&echo, NULL, 0, "+MSGHEX: Done"); tos_at_cmd_exec(&echo, 6000, cmd); if (echo.status == AT_ECHO_STATUS_OK || echo.status == AT_ECHO_STATUS_EXPECT) { - return -1; + return len; } - return len; + return -1; } static int rhf76_close(void)