add lora lowpower at command support

add lora lowpower at command support
This commit is contained in:
supowang
2019-12-18 13:01:35 +08:00
parent d0f61b43a5
commit e1c19fd194
8 changed files with 86 additions and 104 deletions

View File

@@ -3,6 +3,21 @@
static mcps_indication_t rhf76_mcps_indication;
static int rhf76_exit_low_power(void)
{
int try = 0;
at_echo_t echo;
tos_at_echo_create(&echo, NULL, 0, "+LOWPOWER: AUTOOFF");
while (try++ < 10) {
tos_at_cmd_exec(&echo, 3000, RHF76_LOWPOWER_SET);
if (echo.status == AT_ECHO_STATUS_OK || echo.status == AT_ECHO_STATUS_EXPECT) {
return 0;
}
}
return -1;
}
static int rhf76_reset(void)
{
int try = 0;
@@ -186,6 +201,10 @@ static int rhf76_init(void)
printf("Init RHF76 LoRa ...\n" );
at_delay_ms(1000);
if (rhf76_exit_low_power() != 0) {
printf("rhf76 reset FAILED\n");
return -1;
}
if (rhf76_reset() != 0) {
printf("rhf76 reset FAILED\n");

View File

@@ -51,6 +51,9 @@ typedef enum lora_key_type {
} lora_key_type_t;
const char RHF76_LOWPOWER_SET[] = {
0xFF,0xFF,0xFF,0xFF,'A','T','+','L','O','W','P','O','W','E','R','=','a','u','t','o','o','f','f','\r','\n'
};
#define RHF76_ATCMD_SET_CLASS_A "AT+CLASS=A\r\n"
#define RHF76_ATCMD_SET_CLASS_B "AT+CLASS=B\r\n"
#define RHF76_ATCMD_SET_CLASS_C "AT+CLASS=C\r\n"