65 lines
1.2 KiB
C
65 lines
1.2 KiB
C
#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_RECV_STATE = LORA_NRECV;
|
||
|
||
const uint8_t cmd_lora_reset[11] = "AT+REBOOT\r\n";
|
||
const uint8_t cmd_lora_dr5[16] = "AT+CURRENTDR=5\r\n";
|
||
const uint8_t cmd_lora_class[15] = "AT+DEVCLASS=?\r\n";
|
||
|
||
lroa_ctrl_t lora;
|
||
|
||
void InitLoraModule(lroa_ctrl_t *lora)
|
||
{
|
||
RingBuff_Init(&lora->recvRingBuff);
|
||
}
|
||
|
||
void ReadLoraData(RingBuff_t *ringBuff)
|
||
{
|
||
uint32_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)){}
|
||
}
|
||
}
|
||
length = 0;
|
||
}
|
||
|
||
|
||
/*******************************************************************************
|
||
**函数名称:reset_lora()
|
||
**功能描述:复位lora模块
|
||
**入口参数:
|
||
**输出:无
|
||
*******************************************************************************/
|
||
void reset_lora(void)
|
||
{
|
||
UsartxSendDataStr(LORA_USART,cmd_lora_reset,sizeof(cmd_lora_reset));
|
||
}
|
||
|
||
void open_lora(void)
|
||
{
|
||
|
||
}
|
||
|
||
void close_lora(void)
|
||
{
|
||
LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_8);
|
||
}
|
||
|
||
void NetConfig_Lora(void)
|
||
{
|
||
UsartxSendDataStr(LORA_USART,cmd_lora_dr5,sizeof(cmd_lora_dr5));
|
||
}
|
||
|