找回密码
 注册

QQ登录

只需一步,快速开始

搜索

ec20 4g传输光照度、温湿度至阿里云平台 STM32源程序

[复制链接]
路漫漫 发表于 2020-6-7 00:08:09 | 显示全部楼层 |阅读模式
ec20 stm32 阿里云完整源码: sunctrl.7z (2.95 MB, 售价: 1 E币)

部分源码:
  1. #pragma import(__use_no_semihosting)            
  2. //标准库需要的支持函数                 
  3. struct __FILE
  4. {
  5.         int handle;
  6. };

  7. FILE __stdout;      
  8. //定义_sys_exit()以避免使用半主机模式   
  9. void _sys_exit(int x)
  10. {
  11.         x = x;
  12. }
  13. //重定义fputc函数
  14. int fputc(int ch, FILE *f)
  15. {         
  16.         while((USART1->SR&0X40)==0);//循环发送,直到发送完毕   
  17.         USART1->DR = (uint8_t) ch;      
  18.         return ch;
  19. }
  20. #endif

  21. ///////////////////////////////////////////////////////////////



  22. void Usart1SendData_DMA(uint8_t *pdata, uint16_t Length)
  23. {
  24.         // while( huart1.gState != HAL_UART_STATE_READY);
  25.         
  26.         //while(UsartType1.dmaSend_flag == USART_DMA_SENDING);
  27.         UsartType1.dmaSend_flag = USART_DMA_SENDING;
  28.         HAL_UART_Transmit_DMA(&huart1, pdata, Length);
  29.         
  30. }
  31. void Usart2SendData_DMA(uint8_t *pdata, uint16_t Length)
  32. {
  33.          //while( huart2.gState != HAL_UART_STATE_READY);
  34.         
  35.         //while(UsartType2.dmaSend_flag == USART_DMA_SENDING);
  36.         UsartType2.dmaSend_flag = USART_DMA_SENDING;
  37.         HAL_UART_Transmit_DMA(&huart2, pdata, Length);
  38.         
  39. }


  40. void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
  41. {
  42.          __HAL_DMA_DISABLE(huart->hdmatx);
  43.         UsartType1.dmaSend_flag = USART_DMA_SENDOVER;
  44.         UsartType2.dmaSend_flag = USART_DMA_SENDOVER;
  45.         UsartType3.dmaSend_flag = USART_DMA_SENDOVER;
  46. }

  47. void        START_TIM3()
  48. {
  49.         #ifdef        EN_WD
  50.         IDWG_FEED();
  51.         #endif
  52.         //TIM3_Count=0;
  53.         HAL_TIM_Base_Start_IT(&htim3);
  54. }
  55. void END_TIM3()
  56. {
  57.         HAL_TIM_Base_Stop_IT(&htim3);
  58. }
  59. //uint8_t        END_TIM3(uint16_t        n)
  60. //{
  61. //        if(n==0)
  62. //        {
  63. //                HAL_TIM_Base_Stop_IT(&htim3);
  64. //                return        1;
  65. //        }
  66. //        else
  67. //        {
  68. //                if(n<TIM3_Count)
  69. //                {
  70. //                        HAL_TIM_Base_Stop_IT(&htim3);
  71. //                        TIM3_Count=0;
  72. //                        return        1;
  73. //                }
  74. //        }
  75. //        return 0;
  76. //}

  77. void GetMeassage(char *LMeassage)
  78. {

  79.                         char *ret;
  80.                         char buf[20];
  81.                         uint16_t i=0;
  82.                         uint16_t j=0;
  83.                         memset(&buf,0,20);
  84.         
  85. //                j=0;i=0;ret=NULL;
  86. //                ret=strstr(LMeassage,"+QMTSTAT: 0,");
  87. //        
  88. //                        if(ret!=NULL)
  89. //                        {
  90. //                                
  91. //                        }

  92.         

  93. ///////////////////////////////////////////////////Switch1
  94.                   j=0;i=0;ret=NULL;
  95.                         ret=strstr(LMeassage,"Switch1");
  96.                         if(ret!=NULL)
  97.                         {
  98.                                 Rseponse=1;
  99.                                 if(ret[9]=='1')
  100.                                         OPEN(0);
  101.                                 else
  102.                                         {
  103.                                                 CLOSE(0);
  104.                                         }
  105.                         }
  106.                         ///////////////////////////////////////////////////Switch2
  107.                   j=0;i=0;ret=NULL;
  108.                         ret=strstr(LMeassage,"Switch2");
  109.                         if(ret!=NULL)
  110.                         {
  111.                                 Rseponse=1;
  112.                                 if(ret[9]=='1')
  113.                                         OPEN(1);
  114.                                 else
  115.                                         {
  116.                                                 CLOSE(1);
  117.                                         }
  118.                         }
  119.                         ///////////////////////////////////////////////////Switch3
  120.                   j=0;i=0;ret=NULL;
  121.                         ret=strstr(LMeassage,"Switch3");
  122.                         if(ret!=NULL)
  123.                         {
  124.                                 Rseponse=1;
  125.                                 if(ret[9]=='1')
  126.                                         OPEN(2);
  127.                                 else
  128.                                         {
  129.                                                 CLOSE(2);
  130.                                         }
  131.                         }
  132.                         ///////////////////////////////////////////////////Switch4
  133.                   j=0;i=0;ret=NULL;
  134.                         ret=strstr(LMeassage,"Switch4");
  135.                         if(ret!=NULL)
  136.                         {
  137.                                 Rseponse=1;
  138.                                 if(ret[9]=='1')
  139.                                         OPEN(3);
  140.                                 else
  141.                                         {
  142.                                                 CLOSE(3);
  143.                                         }
  144.                         }
  145.                         ///////////////////////////////////////////////////Switch5
  146.                   j=0;i=0;ret=NULL;
  147.                         ret=strstr(LMeassage,"Switch5");
  148.                         if(ret!=NULL)
  149.                         {
  150.                                 Rseponse=1;
  151.                                 if(ret[9]=='1')
  152.                                         OPEN(4);
  153.                                 else
  154.                                         {
  155.                                                 CLOSE(4);
  156.                                         }
  157.                         }
  158.                         ///////////////////////////////////////////////////Switch6
  159.                   j=0;i=0;ret=NULL;
  160.                         ret=strstr(LMeassage,"Switch6");
  161.                         if(ret!=NULL)
  162.                         {
  163.                                 Rseponse=1;
  164.                                 if(ret[9]=='1')
  165.                                         OPEN(5);
  166.                                 else
  167.                                         {
  168.                                                 CLOSE(5);
  169.                                         }
  170.                         }
  171.                         
  172. ///////////////////////////////////////////////////找QRcode
  173.                         j=0;i=0;ret=NULL;
  174.                         ret=strstr(LMeassage,"QRcode");
  175.                 if(ret!=NULL)
  176.                 {
  177.                                                 if(UsartType2.rx_len>1024)
  178.                                                 {
  179.                                                         Meassage.Error_Code=53;//设置二维码error
  180.                                                 }
  181.                                                 //printf("%s",ret+9);
  182.                                                 else
  183.                                                 {
  184.                                                         if(ret[8]=='"')
  185.                                                         {
  186.                                                                 memset(Meassage.QRcode,0,sizeof(Meassage.QRcode));
  187.                                                                
  188.                                                                
  189.                                                                 for(i=0;i<UsartType2.rx_len;i++)
  190.                                                                 {
  191.                                                                         if(ret[9+i]=='"')break;
  192.                                                                         Meassage.QRcode[j]=ret[i+9];
  193.                                                                         j++;
  194.                                                                 }
  195.                                                                 nowSysParam.saveFlag=0x55;
  196.                                                                 memcpy(&nowSysParam.saveData,&Meassage.QRcode,sizeof(Meassage.QRcode)); //????????????
  197.                                                                 w25q_eraseSector(0x0000);
  198.                                                                 w25q_writeNoCheck((uint8_t *)&nowSysParam,0x0000,sizeof(nowSysParam));//???????flash?
  199.                                 
  200.                                                                 Meassage.Error_Code=52;//设置二维码成功
  201.                                                         //        printf("Meassage.QRcode:%s\r\n",Meassage.QRcode);
  202.                                                         
  203.                                                         }
  204.                                                         else
  205.                                                         {
  206.                                                                 Meassage.Error_Code=53;//设置二维码成功失败
  207.                                                         }
  208.                                                 }
  209.                                                         Rseponse=1;
  210.                 }
  211. ……………………

  212. …………限于本文篇幅 余下代码请下载附件…………
复制代码

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

本版积分规则

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

GMT+8, 2024-3-29 20:31

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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