151 lines
6.8 KiB
C
151 lines
6.8 KiB
C
#ifndef _EC20_H
|
||
#define _EC20_H
|
||
#include <stdio.h>
|
||
#include "stm32f10x.h"
|
||
#include "common.h"
|
||
|
||
|
||
|
||
#define CMD_RETRY_TIMES 2
|
||
#define EC20_START_SEND_CMD 0x1A
|
||
#define EC20_BUFFER_LEN 256
|
||
|
||
/*****************************************
|
||
*ec20相关IO
|
||
****************************************/
|
||
#define EC20_POW_PORT GPIOE
|
||
#define EC20_POW_PIN GPIO_Pin_5
|
||
|
||
#define EC20_RST_PORT GPIOE //PE15
|
||
#define EC20_RST_PIN GPIO_Pin_15
|
||
|
||
#define EC20_WAKEUPSTATE_PORT GPIOE
|
||
#define EC20_WAKEUPSTATE_PIN GPIO_Pin_14
|
||
|
||
#define EC20_WAKEUPIN_PORT GPIOB
|
||
#define EC20_WAKEUPIN_PIN GPIO_Pin_12
|
||
|
||
#define EC20_UARTDTR_PORT GPIOE
|
||
#define EC20_UARTDTR_PIN GPIO_Pin_13
|
||
|
||
#define EC20_RFEN_PORT GPIOB
|
||
#define EC20_RFEN_PIN GPIO_Pin_13
|
||
|
||
typedef struct
|
||
{
|
||
char *cmdStr ; //发送命令字符串
|
||
uint16_t revTimeout ; //接收回码超时时间t=revTimeout*100ms
|
||
char *wantReturnStr ; //正确的回码
|
||
RunResult revResult ; //处理结果
|
||
uint8_t rtyNum ; //失败后重发次数
|
||
}EC20_CMD_DATA_s;
|
||
|
||
|
||
#define EC20_CMD_HANDSHAKE "AT\r\n"
|
||
#define EC20_QUERY_VOLTAGE "AT+CBC\r\n"
|
||
|
||
#define EC20_QUERY_CONFIG "AT&V\r\n"
|
||
|
||
#define EC20_SAVE_CONFIG "AT&W\r\n"
|
||
|
||
#define EC20_CMD_CLOSEECHO "ATE0\r\n"
|
||
#define EC20_CMD_OPENECHO "ATE1\r\n"
|
||
|
||
#define EC20_QUERY_NETINFO "AT+QNWINFO\r\n"
|
||
|
||
#define EC20_QUERY_SOFTRELEASE "AT+GMR\r\n"
|
||
|
||
#define EC20_EN_RF "AT+CFUN=1\r\n"
|
||
#define EC20_DISABLE_RF "AT+CFUN=0\r\n"
|
||
|
||
#define EC20_SET_CSSERVICE "AT+CREG=2\r\n"
|
||
#define EC20_QUERY_CSSERVICE "AT+CREG?\r\n"
|
||
|
||
#define EC20_SET_PSSERVICE "AT+CGREG=2\r\n"
|
||
#define EC20_QUERY_PSSERVICE "AT+CGREG?\r\n"
|
||
|
||
#define EC20_QUERY_CSQ "AT+CSQ\r\n"
|
||
#define EC20_QUERY_IMSI "AT+CIMI\r\n"
|
||
#define EC20_QUERY_ICCID "AT+QCCID\r\n"
|
||
|
||
#define EC20_SET_CFGCONTEXT "AT+QICSGP=%d,1,\"CMIOT\",\"\",\"\",1\r\n" //@param1:connectID
|
||
#define EC20_CMD_ACTCONTEXT "AT+QIACT=%d\r\n" //@param1:contextID
|
||
#define EC20_CMD_DEACTCONTEXT "AT+QIDEACT=%d\r\n" //@param1:contextID
|
||
#define EC20_QUERYSTATE_CONTEXE "AT+QIACT?\r\n"
|
||
|
||
/*****************************************************
|
||
TCP相关指令
|
||
******************************************************/
|
||
#define EC20_CMD_CLOSESOCKET "AT+QICLOSE=%d,10\r\n" //@param1:connectID @param2:timeout(S)
|
||
#define EC20_CMD_OPENSOCKET "AT+QIOPEN=%d,%d,\"%s\",\"%s\",%d,%d,%d\r\n" // AT+QIOPEN=1,0,"TCP","120.25.234.195",7001,0,2
|
||
#define EC20_QUERY_SOCKETSTATE "AT+QISTATE=1,%d\r\n" //@param1:1(以connectID判断socket状态) @param2:connectID
|
||
#define EC20_CMD_QISEND "AT+QISEND=%d,%d\r\n" //@param1:connectID @param2:发送定长数据的长度
|
||
|
||
/*****************************************************
|
||
HTTP相关指令
|
||
******************************************************/
|
||
#define EC20_SET_HTTPCLOSETIME "AT+QHTTPCFG=\"closewaittime\",100\r\n"
|
||
#define EC20_SET_HTTPCONTEXT "AT+QHTTPCFG=\"contextid\",%d\r\n" //@param1:contextID
|
||
#define EC20_SET_HTTPREQHEADER "AT+QHTTPCFG=\"requestheader\",1\r\n" //@param1:需要自定义HTTP请求头
|
||
#define EC20_SET_HTTPRESHEADER "AT+QHTTPCFG=\"responseheader\",0\r\n"
|
||
#define EC20_CMD_HTTPURL "AT+QHTTPURL=%d,80\r\n" //@param1:url的长度
|
||
#define EC20_CMD_HTTPPOSTLEN "AT+QHTTPPOST=%ld,6,6\r\n" //@param1:post请求Header+Body的长度 注意:0x0D 0x0A也需要算上
|
||
|
||
#define CARNUM_HTTPPOST_URL "http://www.iotclouddashboard.com\r\n" //长度32
|
||
//#define CARNUM_HTTPPOST_URL "http://120.25.153.123:8080/park/barrierCharge/touched/\r\n" //长度54
|
||
#define CARNUM_HTTPPOST_HEADERBODY "POST http://www.iotclouddashboard.com/park/barrierCharge/touched/ HTTP/1.1\r\nContent-Type:application/json;charset=UTF-8\r\nHost:www.iotclouddashboard.com\r\ncontent-length:%d\r\n\r\n{\"cardNumber\":\"%s\",\"mac\":\"%s\",\"largeCar\":%s}\r\n"
|
||
//@param1 %d:body长度。 @param2%s:carNum字符串 @param3%s: mac字符串 @param4%s: carType字符串
|
||
|
||
|
||
#define LOCALCARNUM_HTTPPOST_HEADERBODY "POST http://www.iotclouddashboard.com/park/barrierCharge/touchedMonthUser/ HTTP/1.1\r\nContent-Type:application/json;charset=UTF-8\r\nHost:www.iotclouddashboard.com\r\ncontent-length:%d\r\n\r\n{\"cardNumber\":\"%s\",\"mac\":\"%s\",\"largeCar\":%s}\r\n"
|
||
//@param1 %d:body长度。 @param2%s:carNum字符串 @param3%s: mac字符串 @param4%s: carType字符串
|
||
|
||
|
||
#define MONTHUSER_HTTPPOST_URL "http://www.iotclouddashboard.com\r\n" //长度26 www.iotclouddashboard.com
|
||
#define MONTHUSERSUM_HTTPPOST_HEADERBODY "POST http://www.iotclouddashboard.com/park/monthUser/getAmountBarrier/ HTTP/1.1\r\nContent-Type:application/json;charset=UTF-8\r\nHost:www.iotclouddashboard.com\r\ncontent-length:34\r\n\r\n{\"mac\":\"%s\"}\r\n"
|
||
//@param1 %d:body长度。 @param2%s: mac字符串
|
||
#define MONTHUSERLIST_HTTPPOST_HEADERBODY "POST http://www.iotclouddashboard.com/park/monthUser/getDataBarrier/ HTTP/1.1\r\nContent-Type:application/json;charset=UTF-8\r\nHost:www.iotclouddashboard.com\r\ncontent-length:44\r\n\r\n{\"mac\":\"%s\",\"order\":%d}\r\n"
|
||
//@param1 %d:body长度。 @param2%s: mac字符串 @param3 %d:请求第几组数据。
|
||
|
||
//#define REG_HTTPPOST_URL "http://120.25.153.123:8080/park/barrierCharge/getTypeByMac/\r\n" //长度54+5
|
||
#define REG_HTTPPOST_HEADERBODY "POST http://www.iotclouddashboard.com/park/barrierCharge/getTypeByMac/ HTTP/1.1\r\nContent-Type:application/json;charset=UTF-8\r\nHost:www.iotclouddashboard.com\r\ncontent-length:%d\r\n\r\n{\"mac\":\"%s\"}\r\n"
|
||
//@param1 %d:body长度。 @param2%s: mac字符串
|
||
|
||
#define REG_HTTPPOST_URL "http://www.iotclouddashboard.com\r\n" //长度32
|
||
//#define REG_HTTPPOST_HEADERBODY "POST http://120.25.159.154:8090/park/barrierCharge/getTypeByMac/ HTTP/1.1\r\nContent-Type:application/json;charset=UTF-8\r\nHost:120.25.153.123:8080\r\ncontent-length:%d\r\n\r\n{\"mac\":\"%s\"}\r\n"
|
||
|
||
#define EC20_QUERY_HTTPPOSTDATA "AT+QHTTPREAD=80\r\n"
|
||
|
||
//typedef enum
|
||
//{
|
||
// BUFFER_ACCESS = 0 ,
|
||
// DIRECT_PUSH = 1 ,
|
||
// TRANSPARENET_ACCESS = 2
|
||
//} ACCESS_MODE ;
|
||
|
||
typedef struct
|
||
{
|
||
uint8_t tcpContextID ; //TCP链路
|
||
uint8_t tcpConnectID0 ; //出入口Socket
|
||
uint8_t tcpConnectID1 ; //诱导牌Socket
|
||
uint8_t tcpLocalPort ;
|
||
uint8_t httpContextID ; //HTTP链路
|
||
// ACCESS_MODE access_mode ;
|
||
}NetParameter_s ;
|
||
|
||
/*****************************************
|
||
*内部函数声明
|
||
****************************************/
|
||
void EC20_GPIO_Init( void ) ;
|
||
void EC20_POWON(void) ;
|
||
void EC20_POWOFF(void) ;
|
||
RunResult EC20_START(void) ;
|
||
|
||
/*****************************************
|
||
*对外接口函数声明
|
||
****************************************/
|
||
extern void LTE_Receive_Data_Callback(uint8_t rxData) ;
|
||
extern ErrorStatus EC20_Module_Init( void ) ;
|
||
|
||
#endif
|