stm32_ota/HARDWARE/MODULE/EC20/EC20.h

151 lines
6.8 KiB
C
Raw Normal View History

2023-12-15 06:28:06 +00:00
#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<EFBFBD><EFBFBD><EFBFBD><EFBFBD>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 ; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
uint16_t revTimeout ; //<2F><><EFBFBD>ջ<EFBFBD><D5BB>볬ʱʱ<CAB1><CAB1>t=revTimeout*100ms
char *wantReturnStr ; //<2F><>ȷ<EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD>
RunResult revResult ; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
uint8_t rtyNum ; //ʧ<>ܺ<EFBFBD><DCBA>ط<EFBFBD><D8B7><EFBFBD><EFBFBD><EFBFBD>
}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<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
******************************************************/
#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(<28><>connectID<49>ж<EFBFBD>socket״̬) @param2:connectID
#define EC20_CMD_QISEND "AT+QISEND=%d,%d\r\n" //@param1:connectID @param2:<3A><><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵij<DDB5><C4B3><EFBFBD>
/*****************************************************
HTTP<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
******************************************************/
#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:<3A><>Ҫ<EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>HTTP<54><50><EFBFBD><EFBFBD>ͷ
#define EC20_SET_HTTPRESHEADER "AT+QHTTPCFG=\"responseheader\",0\r\n"
#define EC20_CMD_HTTPURL "AT+QHTTPURL=%d,80\r\n" //@param1:url<72>ij<EFBFBD><C4B3><EFBFBD>
#define EC20_CMD_HTTPPOSTLEN "AT+QHTTPPOST=%ld,6,6\r\n" //@param1:post<73><74><EFBFBD><EFBFBD>Header+Body<64>ij<EFBFBD><C4B3><EFBFBD> ע<>⣺0x0D 0x0AҲ<41><D2B2>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>
#define CARNUM_HTTPPOST_URL "http://www.iotclouddashboard.com\r\n" //<2F><><EFBFBD><EFBFBD>32
//#define CARNUM_HTTPPOST_URL "http://120.25.153.123:8080/park/barrierCharge/touched/\r\n" //<2F><><EFBFBD><EFBFBD>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<64><79><EFBFBD>ȡ<EFBFBD> @param2%s:carNum<75>ַ<EFBFBD><D6B7><EFBFBD> @param3%s: mac<61>ַ<EFBFBD><D6B7><EFBFBD> @param4%s: carType<70>ַ<EFBFBD><D6B7><EFBFBD>
#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<64><79><EFBFBD>ȡ<EFBFBD> @param2%s:carNum<75>ַ<EFBFBD><D6B7><EFBFBD> @param3%s: mac<61>ַ<EFBFBD><D6B7><EFBFBD> @param4%s: carType<70>ַ<EFBFBD><D6B7><EFBFBD>
#define MONTHUSER_HTTPPOST_URL "http://www.iotclouddashboard.com\r\n" //<2F><><EFBFBD><EFBFBD>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<64><79><EFBFBD>ȡ<EFBFBD> @param2%s: mac<61>ַ<EFBFBD><D6B7><EFBFBD>
#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<64><79><EFBFBD>ȡ<EFBFBD> @param2%s: mac<61>ַ<EFBFBD><D6B7><EFBFBD> @param3 %d:<3A><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD><DABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD>
//#define REG_HTTPPOST_URL "http://120.25.153.123:8080/park/barrierCharge/getTypeByMac/\r\n" //<2F><><EFBFBD><EFBFBD>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<64><79><EFBFBD>ȡ<EFBFBD> @param2%s: mac<61>ַ<EFBFBD><D6B7><EFBFBD>
#define REG_HTTPPOST_URL "http://www.iotclouddashboard.com\r\n" //<2F><><EFBFBD><EFBFBD>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<43><50>·
uint8_t tcpConnectID0 ; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Socket
uint8_t tcpConnectID1 ; //<2F>յ<EFBFBD><D5B5><EFBFBD>Socket
uint8_t tcpLocalPort ;
uint8_t httpContextID ; //HTTP<54><50>·
// ACCESS_MODE access_mode ;
}NetParameter_s ;
/*****************************************
*<EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
****************************************/
void EC20_GPIO_Init( void ) ;
void EC20_POWON(void) ;
void EC20_POWOFF(void) ;
RunResult EC20_START(void) ;
/*****************************************
*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿں<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
****************************************/
extern void LTE_Receive_Data_Callback(uint8_t rxData) ;
extern ErrorStatus EC20_Module_Init( void ) ;
#endif