已在实际项目中使用
单片机源程序如下:
- #include <string.h>
- #include "sim800c.h"
- #include "stm32f10x_gpio.h"
- //extern Ring_Fifo g_up_fifo;
- #if 1
- int8_t at_cmd_ans(uint8_t *ack);
- int8_t sim800c_net_init(void);
- int8_t net_remote_close(void);
- void sim800c_power_reset(void);
- void sim800c_cmd_mode_sw(void);
- void sim800c_mode_switch(void);
- #endif
- //extern System_Param parm;
- ModemTypedef g_modem_status;
- uint8_t at_cmd_buf[128];
- uint16_t at_len;
- #define MOEM_INITCMD_LEN 13 //13
- uint8_t *init_cmd_list[MOEM_INITCMD_LEN]=
- {
- "AT\r",
- "ATZ\r",
- "ATE0&W\r",
- "ATS0=0\r",
- "AT+CMEE=0\r",
- "AT+CSDT=0\r",
- "AT+CSCLK=0\r",*
- "AT+CMGD=1,4\r",
- "AT+CMGF=1\r",
- "AT+CIPSHUT\r",
- "AT+CIPMUX=0\r", // 单链路模式
- "AT+CIPMODE=1\r", // 透传模式
- "AT+CIPSPRT=1\r",
- } ;
- uint8_t send_data_to_server(uint8_t *data, uint16_t len)
- {
- //data[len] = 0x0d;
-
- Uart2TxData(data, len );
- UsartBkTxLen("\r\nsend to server:", 17 );
- UsartBkTxLen(data, len+1 );
- UsartBkTxLen("\r\n", 2 );
- //clear_up_uart_fifo();
- return SUCCESS;
- }
- /**************************************************************************
- **************************************************************************/
- void sim800c_init(void)
- {
-
- GSM_POWER_H();
- g_modem_status.wait_timer = 305;
- g_modem_status.modem_err_cnt = 0;
- at_len = 0;
- g_modem_status.wait = 0;
- }
- /**************************************************************************
- **************************************************************************/
- void sim800c_power_reset(void)
- {
- GSM_POWER_L();
- g_modem_status.wait_timer = 105;
- at_len = 0;
- g_modem_status.modem_err_cnt = 0;
- }
- /**************************************************************************
- **************************************************************************/
- void reset_modem_status(void)
- {
- g_modem_status.cmd_index=0;
- g_modem_status.modem_err_cnt=0;
- g_modem_status.wait =0;
- g_modem_status.wait_timer=0;
- }
- /**************************************************************************
- 发送数据提示
- **************************************************************************/
- uint8_t at_send_data_cmd(void)
- {
- uint8_t res;
- res= send_at_cmd("AT+CIPSEND\r",">","ERROR",200 );
- if(res != SUCCESS)
- {
- res=0x1B;
- send_at_cmd(&res,NULL,NULL,0);
- DelayMs_hal(1);
- sim800c_cmd_mode_sw();
- return ERROR;
- }
- else
- {
- return SUCCESS;
- }
- }
- /**************************************************************************
- 发送数据到网络
- **************************************************************************/
- uint8_t send_data_ack(void)
- {
- uint8_t tmp=0x1A;
- if(SUCCESS ==send_at_cmd(&tmp,"SEND OK\0x0D\0x0A",NULL,550))
- {
- //clear_up_uart_fifo();
- return SUCCESS;
- }
- else
- {
- //clear_up_uart_fifo();
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
sim7600ce.zip
(4.4 KB, 下载次数: 210)
|