找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 5371|回复: 14
收起左侧

STM32_sim7600ce4G模块与服务器通讯代码,已上线使用

  [复制链接]
ID:197430 发表于 2019-9-18 02:16 | 显示全部楼层 |阅读模式
已在实际项目中使用

单片机源程序如下:
  1. #include <string.h>
  2. #include "sim800c.h"
  3. #include "stm32f10x_gpio.h"

  4. //extern Ring_Fifo g_up_fifo;

  5. #if 1
  6. int8_t at_cmd_ans(uint8_t *ack);

  7. int8_t sim800c_net_init(void);
  8. int8_t net_remote_close(void);
  9. void sim800c_power_reset(void);
  10. void sim800c_cmd_mode_sw(void);
  11. void sim800c_mode_switch(void);


  12. #endif
  13. //extern System_Param parm;
  14. ModemTypedef g_modem_status;

  15. uint8_t at_cmd_buf[128];
  16. uint16_t at_len;
  17. #define MOEM_INITCMD_LEN                                 13 //13
  18. uint8_t *init_cmd_list[MOEM_INITCMD_LEN]=
  19. {
  20.         "AT\r",
  21.         "ATZ\r",
  22.         "ATE0&W\r",
  23.         "ATS0=0\r",
  24.         "AT+CMEE=0\r",
  25.         "AT+CSDT=0\r",
  26.         "AT+CSCLK=0\r",*
  27.         "AT+CMGD=1,4\r",
  28.         "AT+CMGF=1\r",
  29.         "AT+CIPSHUT\r",
  30.         "AT+CIPMUX=0\r", // 单链路模式
  31.         "AT+CIPMODE=1\r",   // 透传模式
  32.         "AT+CIPSPRT=1\r",
  33. }        ;

  34. uint8_t send_data_to_server(uint8_t *data, uint16_t len)
  35. {
  36.         //data[len] = 0x0d;       
  37.        
  38.         Uart2TxData(data, len );

  39.         UsartBkTxLen("\r\nsend to server:", 17 );
  40.         UsartBkTxLen(data, len+1 );
  41.         UsartBkTxLen("\r\n", 2 );
  42.   //clear_up_uart_fifo();
  43.         return SUCCESS;
  44. }


  45. /**************************************************************************
  46. **************************************************************************/
  47. void sim800c_init(void)
  48. {
  49.        
  50.         GSM_POWER_H();
  51.         g_modem_status.wait_timer = 305;
  52.           g_modem_status.modem_err_cnt = 0;

  53.         at_len = 0;
  54.         g_modem_status.wait = 0;
  55. }

  56. /**************************************************************************
  57. **************************************************************************/
  58. void sim800c_power_reset(void)
  59. {
  60.   GSM_POWER_L();
  61.   g_modem_status.wait_timer = 105;
  62.   at_len = 0;
  63.   g_modem_status.modem_err_cnt = 0;
  64. }

  65. /**************************************************************************
  66. **************************************************************************/
  67. void reset_modem_status(void)
  68. {
  69.          g_modem_status.cmd_index=0;
  70.          g_modem_status.modem_err_cnt=0;
  71.          g_modem_status.wait =0;
  72.          g_modem_status.wait_timer=0;
  73. }


  74. /**************************************************************************
  75. 发送数据提示
  76. **************************************************************************/
  77. uint8_t at_send_data_cmd(void)
  78. {
  79.         uint8_t res;
  80.         res= send_at_cmd("AT+CIPSEND\r",">","ERROR",200 );
  81.         if(res != SUCCESS)
  82.         {
  83.                   res=0x1B;
  84.                   send_at_cmd(&res,NULL,NULL,0);
  85.                   DelayMs_hal(1);
  86.                   sim800c_cmd_mode_sw();
  87.                   return ERROR;
  88.         }
  89.         else
  90.         {
  91.                  return SUCCESS;
  92.         }
  93. }

  94. /**************************************************************************
  95. 发送数据到网络
  96. **************************************************************************/
  97. uint8_t send_data_ack(void)
  98. {
  99.           uint8_t tmp=0x1A;
  100.          if(SUCCESS ==send_at_cmd(&tmp,"SEND OK\0x0D\0x0A",NULL,550))
  101.          {
  102.                  //clear_up_uart_fifo();
  103.                  return SUCCESS;
  104.          }
  105.          else
  106.          {
  107.                  //clear_up_uart_fifo();
  108. ……………………

  109. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
0.png

所有资料51hei提供下载:
sim7600ce.zip (4.4 KB, 下载次数: 210)

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

回复

使用道具 举报

ID:612915 发表于 2019-9-18 09:26 | 显示全部楼层
好东西
回复

使用道具 举报

ID:459918 发表于 2019-9-18 14:12 | 显示全部楼层
好的,感觉这个不错啊
回复

使用道具 举报

ID:614883 发表于 2019-9-22 18:47 | 显示全部楼层
好东西哦
回复

使用道具 举报

ID:337376 发表于 2019-10-30 11:44 | 显示全部楼层
谢谢分享,参考下
回复

使用道具 举报

ID:157108 发表于 2019-10-31 13:58 | 显示全部楼层
好东西,想要!
回复

使用道具 举报

ID:652314 发表于 2019-11-29 13:13 | 显示全部楼层
围观学习
回复

使用道具 举报

ID:628866 发表于 2019-12-20 09:48 | 显示全部楼层
你这是sim800c不是7600ce呀老铁
回复

使用道具 举报

ID:294886 发表于 2020-3-19 11:22 | 显示全部楼层
谢谢,每次都在黑子论坛找到代码!
回复

使用道具 举报

ID:284155 发表于 2020-4-1 07:44 | 显示全部楼层
下载下来试试
回复

使用道具 举报

ID:773912 发表于 2020-6-9 13:54 | 显示全部楼层
好东西,想要
回复

使用道具 举报

ID:784496 发表于 2021-8-10 17:07 | 显示全部楼层
感觉不错,是我想找得
回复

使用道具 举报

ID:584195 发表于 2021-8-11 06:50 | 显示全部楼层
楼主,总是分享好东西!学习了。
回复

使用道具 举报

ID:496991 发表于 2021-8-19 11:40 | 显示全部楼层
你这个是sim800,不是sim7600……
回复

使用道具 举报

ID:584195 发表于 2021-8-19 15:41 | 显示全部楼层
我以前操作就是搞不好,谢谢了~
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表