找回密码
 注册

QQ登录

只需一步,快速开始

搜索

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. }
复制代码
1.png 2.png 3.png 4.png 5.png
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|ELEOK |网站地图

GMT+8, 2024-4-20 17:17

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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