94 lines
2.4 KiB
C
94 lines
2.4 KiB
C
|
|
#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)
|
|
|
|
//网络注册状态
|
|
typedef enum
|
|
{
|
|
QUECTEL_NET_NOT = 0, //未注册
|
|
QUECTEL_NET_YES = 1, //已经注册
|
|
QUECTEL_NET_SEA = 2, //未注册,正在搜索
|
|
QUECTEL_NET_TUR = 3, //注册被拒绝
|
|
QUECTEL_NET_UNK = 4, //未知
|
|
QUECTEL_NET_ROA = 5, //已经注册,但是漫游
|
|
SQUECTEL_NET_ERROR=0XFF //错误
|
|
}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
|