找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

帖子
查看: 6580|回復(fù): 14
打印 上一主題 下一主題
收起左側(cè)

STM32_sim7600ce4G模塊與服務(wù)器通訊代碼,已上線使用

  [復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
已在實(shí)際項(xiàng)目中使用

單片機(jī)源程序如下:
  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",   // 透?jìng)髂J?br />
  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. 發(fā)送數(shù)據(jù)提示
  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. 發(fā)送數(shù)據(jù)到網(wǎng)絡(luò)
  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. …………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
復(fù)制代碼


所有資料51hei提供下載:
sim7600ce.zip (4.4 KB, 下載次數(shù): 210)

評(píng)分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏7 分享淘帖 頂1 踩
回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:612915 發(fā)表于 2019-9-18 09:26 | 只看該作者
好東西
回復(fù)

使用道具 舉報(bào)

板凳
ID:459918 發(fā)表于 2019-9-18 14:12 | 只看該作者
好的,感覺這個(gè)不錯(cuò)啊
回復(fù)

使用道具 舉報(bào)

地板
ID:614883 發(fā)表于 2019-9-22 18:47 | 只看該作者
好東西哦
回復(fù)

使用道具 舉報(bào)

5#
ID:337376 發(fā)表于 2019-10-30 11:44 | 只看該作者
謝謝分享,參考下
回復(fù)

使用道具 舉報(bào)

6#
ID:157108 發(fā)表于 2019-10-31 13:58 | 只看該作者
好東西,想要!
回復(fù)

使用道具 舉報(bào)

7#
ID:652314 發(fā)表于 2019-11-29 13:13 | 只看該作者
圍觀學(xué)習(xí)
回復(fù)

使用道具 舉報(bào)

8#
ID:628866 發(fā)表于 2019-12-20 09:48 | 只看該作者
你這是sim800c不是7600ce呀老鐵
回復(fù)

使用道具 舉報(bào)

9#
ID:294886 發(fā)表于 2020-3-19 11:22 | 只看該作者
謝謝,每次都在黑子論壇找到代碼!
回復(fù)

使用道具 舉報(bào)

10#
ID:284155 發(fā)表于 2020-4-1 07:44 | 只看該作者
下載下來(lái)試試
回復(fù)

使用道具 舉報(bào)

11#
ID:773912 發(fā)表于 2020-6-9 13:54 | 只看該作者
好東西,想要
回復(fù)

使用道具 舉報(bào)

12#
ID:784496 發(fā)表于 2021-8-10 17:07 | 只看該作者
感覺不錯(cuò),是我想找得
回復(fù)

使用道具 舉報(bào)

13#
ID:584195 發(fā)表于 2021-8-11 06:50 | 只看該作者
樓主,總是分享好東西!學(xué)習(xí)了。
回復(fù)

使用道具 舉報(bào)

14#
ID:496991 發(fā)表于 2021-8-19 11:40 | 只看該作者
你這個(gè)是sim800,不是sim7600……
回復(fù)

使用道具 舉報(bào)

15#
ID:584195 發(fā)表于 2021-8-19 15:41 | 只看該作者
我以前操作就是搞不好,謝謝了~
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表