Teste Flash
Dependencies: pulga-lorawan-drv Si1133 BME280
serial_cmds.cpp
00001 #include "serial.h" 00002 00003 gps_navPVT gps_data; 00004 00005 bool SerialCommandRun(const char *msg) 00006 { 00007 char Option = msg[1]; /// recebo opcao 00008 00009 switch (Option) 00010 { 00011 00012 case CMD_PRINT_LAST_GPS: 00013 {int local_lat, local_log; 00014 00015 gps_data = get_struct(); 00016 pc.printf("<g%d,%d\n>", (int)gps_data.lat, (int)gps_data.lon); 00017 pc.printf("<t%d/%d/%d-%d:%d:%d\n>", (int)gps_data.year, (int)gps_data.month,(int)gps_data.day, (int)gps_data.hour, (int)gps_data.min, (int)gps_data.sec); 00018 00019 break;} 00020 00021 case CMD_SEND_HELLO: 00022 {pc.printf("<hHello>"); 00023 char hello[100] = "helloWord\n"; 00024 int ret; 00025 ret = lora_send_message((uint8_t*)hello, (uint16_t)strlen(hello)); 00026 if(ret > 0){ 00027 pc.printf("Send OK\n"); 00028 } 00029 else{ 00030 ret == LORAWAN_STATUS_WOULD_BLOCK ? pc.printf("send - WOULD BLOCK\r\n") : pc.printf("\r\n send() Error \r\n"); 00031 //if (ret == LORAWAN_STATUS_WOULD_BLOCK) { 00032 //retry in 3 seconds 00033 //if (MBED_CONF_LORA_DUTY_CYCLE_ON) { 00034 //ev_queue.call_in(10000, send_message); 00035 pc.printf("Fail to Send\n"); 00036 } 00037 break;} 00038 case CMD_SEND_LORAWAN_NO_RETRANS: 00039 {pc.printf("<w %s>", msg+2); 00040 char msg_lora [256]; 00041 strncpy(msg_lora, msg+2, strlen(msg)); //original string, begin index (2), substring length 00042 int ret1; 00043 ret1 = lora_send_message((uint8_t*)msg_lora, (uint16_t)strlen(msg_lora)); 00044 if(ret1 > 0){ 00045 pc.printf("Send OK\n"); 00046 } 00047 else{ 00048 ret1 == LORAWAN_STATUS_WOULD_BLOCK ? pc.printf("send - WOULD BLOCK\r\n") : pc.printf("\r\n send() Error \r\n"); 00049 //if (ret == LORAWAN_STATUS_WOULD_BLOCK) { 00050 //retry in 3 seconds 00051 //if (MBED_CONF_LORA_DUTY_CYCLE_ON) { 00052 //ev_queue.call_in(10000, send_message); 00053 pc.printf("Fail to Send\n"); 00054 } 00055 break;} 00056 00057 case CMD_SEND_LORAWAN_RETRANS: 00058 {pc.printf("<w %s>", msg+2); 00059 char msg_lora_retrans [256]; 00060 strncpy(msg_lora_retrans, msg+2, strlen(msg)); //original string, begin index (2), substring length 00061 int ret2; 00062 ret2 = lora_send_message((uint8_t*)msg_lora_retrans, (uint16_t)strlen(msg_lora_retrans)); 00063 if(ret2 > 0){ 00064 pc.printf("Send OK\n"); 00065 } 00066 else{ 00067 ret2 == LORAWAN_STATUS_WOULD_BLOCK ? pc.printf("send - WOULD BLOCK\r\n") : pc.printf("\r\n send() Error \r\n"); 00068 if (ret2 == LORAWAN_STATUS_WOULD_BLOCK) { 00069 //retry in 3 seconds 00070 if (MBED_CONF_LORA_DUTY_CYCLE_ON) { 00071 //ev_queue.call_in(10000, lora_send_message); 00072 wait_ms(3000); 00073 ret2 = lora_send_message((uint8_t*)msg_lora_retrans, (uint16_t)strlen(msg_lora_retrans)); 00074 } 00075 pc.printf("Fail to Send\n");} 00076 } 00077 break;} 00078 } 00079 00080 return true; 00081 }
Generated on Tue Jul 12 2022 23:46:18 by 1.7.2