1.5wuling_zhuanjietou/SYSTEM/4G_EC200_Handle.h

94 lines
2.4 KiB
C
Raw Normal View History

2024-10-17 01:06:51 +00:00
#ifndef __4G_EC200_HANDLE_H
#define __4G_EC200_HANDLE_H
#include "stdint.h"
#define QUECTEL_RecvBuff Uart1_get_data_buff()
#define QUECTEL_Get_RecvBuff_Len() Uart1_Get_DataLen()
#define QUECTEL_RecvData_Flag UART_Network_RecvFinish
#define QUECTEL_Clear_RecvFlag() UART_Network_RecvFinish=0
#define QUECTEL_Send(data, datalen) do{UartPrint(USART1, data, datalen);}while(0)
#define QUECTEL_Clear_RecvData() Uart1_Clear_Buffer()
typedef struct _quectel_handle_t quectel_handle_t;
typedef enum
{
QUECTEL_CMD_AT = 0,
QUECTEL_CMD_ATE = 1,
QUECTEL_CMD_CPIN = 2,
QUECTEL_CMD_CREG = 3,
QUECTEL_CMD_CGREG = 4,
QUECTEL_CMD_CGDCONT = 5,
QUECTEL_CMD_CGATT = 6,
QUECTEL_CMD_QIOPEN = 7,
QUECTEL_CMD_QISEND = 8,
QUECTEL_CMD_QICLOSE = 9,
QUECTEL_CMD_CMEE = 10,
QUECTEL_CMD_QISTATE = 11,
QUECTEL_CMD_ENTER_AT =12,
QUECTEL_CMD_ATO = 13,
QUECTEL_CMD_WAIT,
QUECTEL_CMD_RECV,
}QUECTEL_ATCMD;
typedef enum
{
ATCMD_STATE_INIT_SEND = 0,
ATCMD_STATE_INIT_RECV = 1,
ATCMD_STATE_INIT_WAIT = 2,
ATCMD_STATE_TCP_CONNECT = 3,
ATCMD_STATE_TCP_CONNECT_RECV = 4,
ATCMD_STATE_TCP_WAIT = 5,
ATCMD_STATE_TCP_LOOP = 6,
ATCMD_STATE_REBOOT = 7,
}QUECTEL_STATE;
#define QUECTEL_SET(phandle, cmd, waitcmd, time) do{phandle->at_cmd=cmd;\
phandle->repeat_cnt++;\
phandle->wait_time=time;\
Wait_Timeout_Reload(&phandle->timeout);\
phandle->module_state=waitcmd;}while(0)
#define QUECTEL_CMD_SET(phandle) do{phandle->at_cmd=QUECTEL_CMD_WAIT;\
Wait_Timeout_Reload(&phandle->timeout);}while(0)
//<2F><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>״̬
typedef enum
{
QUECTEL_NET_NOT = 0, //δע<CEB4><D7A2>
QUECTEL_NET_YES = 1, //<2F>Ѿ<EFBFBD>ע<EFBFBD><D7A2>
QUECTEL_NET_SEA = 2, //δע<CEB4><D7A2>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
QUECTEL_NET_TUR = 3, //ע<><EFBFBD>ܾ<EFBFBD>
QUECTEL_NET_UNK = 4, //δ֪
QUECTEL_NET_ROA = 5, //<2F>Ѿ<EFBFBD>ע<EFBFBD><D7A2>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SQUECTEL_NET_ERROR=0XFF //<2F><><EFBFBD><EFBFBD>
}QUECTEL_NETSTATUS;
typedef struct _quectel_handle_t
{
QUECTEL_STATE module_state;
QUECTEL_ATCMD at_cmd;
QUECTEL_NETSTATUS NetStatus;
QUECTEL_NETSTATUS GPRSStatus;
int repeat_cnt;
int timeout_cnt;
int reboot_cnt;
int wait_time;
uint32_t timeout;
uint32_t period_timeout;
void (*at_send)(char *data, uint16_t datalen);
int (*at_resp)(char *resp, char *except);
} quectel_handle_t;
extern quectel_handle_t quectel_handle;
extern void Quectel_Reset_Connect(void);
extern void Quectel_Process(quectel_handle_t *phandle, char *apn, char *addr, int port);
extern void Quectel_Test(void);
#endif