国产免费AV|泡泡玛特欧洲总部将设在伦敦|中文天堂网www新版资源在线|一本久道综合在线中文|国精产品一二三产区的使用方法|香蕉鱼在线观看|www.27eee

 找回密碼
 注冊
搜索

STM32+GSM(SIM900A)模塊通過服務器實現網絡授時源碼(僅供參考學習)

[復制鏈接]
樓主
路漫漫 發表于 2020-5-25 00:46:04 | 只看該作者 |只看大圖 |倒序瀏覽 |閱讀模式
對使用GSM模塊使用有挺大參考作用,使用串口與CDNA指令完成。希望幫到大家學習
GSM通過服務器或內部網絡授源碼.zip (339.03 KB, 售價: 1 E幣)
部分源碼
  1. /**
  2.   ******************************************************************************
  3.   * @file    main.c
  4.   * @version V1.0
  5.   * @brief   用3.5.0版本庫建的工程模板
  6.   ******************************************************************************
  7.   * @attention
  8.   *
  9.   * 實驗平臺: STM32F103CT6核心板
  10.   * 實驗內容:GSM(SIM900A)模塊通過服務器實現網絡授時
  11. *經實驗測試和改善后目前已初步達到實驗目的,但
  12.   *           穩定性方面略微存在一些欠缺,請學習者自行改善,僅供學習,不得用于其他用途
  13.   ******************************************************************************
  14.   */
  15.   
  16. #include "stm32f10x.h"
  17. #include "GSM.h"
  18. #include "AT_Cmd.h"
  19. #include "usart2.h"
  20. #include "usart1.h"
  21. #include "delay.h"
  22. #include "string.h"
  23. #include "rtc.h"
  24. #include "Get_net_time.h"

  25. /**
  26.   * @brief  主函數
  27.   * @param  無
  28.   * @retval 無
  29.   */
  30. int main(void)
  31. {
  32.     u8 res;
  33.    
  34.     delay_init();
  35.     Usart2_Init(115200);    //初始化串口2
  36.     delay_ms(3);
  37.     Usart1_Init(115200);    //初始化串口1
  38.    
  39.     if(RTC_Init()==0)
  40.         printf("RTC初始化成功\r\n");
  41.     else
  42.         printf("RTC初始化失敗\r\n");
  43.    
  44.     printf("初始化SIM900A中...\r\n");
  45.    
  46.     res=1;
  47.     while(res)
  48.     {
  49.         res=GSM_Dect();
  50.         delay_ms(2000);
  51.     }
  52.     res=1;
  53. //    while(res)
  54. //    {
  55. //        res=SIM900A_CONNECT_SERVER_SEND_INFOR((u8*)"time.nist.gov",(u8*)"13");//連接授時服務器(國外)
  56. //    }
  57. //    Get_Sever_Time();//提取獲取到的時間并存入STM32和GSM模塊內部RTC中
  58.     Get_GSM_RTCtime();//直接從GSM模塊內部獲取時間,初次上電時需要手動復位
  59.    
  60.     printf("\r\n系統初始化完成\r\n");
  61.         while(1)
  62.       {
  63.           display_time();//顯示STM32內部RTC的時間
  64.           delay_ms(1000);
  65.       }

  66. }
復制代碼
STM32+GSM(SIM900A)模塊通過服務器實現網絡授時源碼(僅供參考學習) 1.png STM32+GSM(SIM900A)模塊通過服務器實現網絡授時源碼(僅供參考學習) 2.png STM32+GSM(SIM900A)模塊通過服務器實現網絡授時源碼(僅供參考學習) 3.png STM32+GSM(SIM900A)模塊通過服務器實現網絡授時源碼(僅供參考學習) 4.png STM32+GSM(SIM900A)模塊通過服務器實現網絡授時源碼(僅供參考學習) 5.png
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規則

手機版|小黑屋|ELEOK |網站地圖

GMT+8, 2026-5-26 01:06

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回復 返回頂部 返回列表