#include "lora.h" #include "main.h" #include "fifo.h" #include "user_data_send.h" volatile uint8_t LORA_STATE = LORA_NOT_JOIN; //volatile uint8_t LORA_STATE = LORA_JOINED; volatile uint8_t LORA_RECV_STATE = DISABLE; const uint8_t cmd_lora_reset[11] = "AT+REBOOT\r\n"; const uint8_t cmd_lora_dr2[16] = "AT+ =2\r\n"; lroa_ctrl_t lora; void InitLoraModule(lroa_ctrl_t *lora) { RingBuff_Init(&lora->recvRingBuff); } uint8_t ReadLoraData(RingBuff_t *ringBuff) { uint8_t ret = 0; uint8_t length = 0; uint8_t recdata[1]; while(Read_RingBuff(ringBuff,recdata)) { lora.loraData[length] = recdata[0]; length++; if(length >= LORA_DATA_LENGTH) { while(Read_RingBuff(ringBuff,recdata)){} } } ret = length; length = 0; return ret; } /******************************************************************************* **函数名称:reset_lora() **功能描述:复位lora模块 **入口参数: **输出:无 *******************************************************************************/ void reset_lora(void) { UsartxSendDataStr(LORA_USART,cmd_lora_reset,sizeof(cmd_lora_reset)); } void open_lora(void) { LL_GPIO_SetOutputPin(GPIOB, LL_GPIO_PIN_5); } void close_lora(void) { LL_GPIO_ResetOutputPin(GPIOB, LL_GPIO_PIN_5); } void NetConfig_Lora(void) { UsartxSendDataStr(LORA_USART,cmd_lora_dr2,sizeof(cmd_lora_dr2)); }