sys_http.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "httpclient.h"
  2. #include "string.h"
  3. #include "stdio.h"
  4. #include "main.h"
  5. #include "sys_http.h"
  6. #include "FreeRTOS.h"
  7. #include "task.h"
  8. #include "log.h"
  9. #include "gd32_flash.h"
  10. //http配置标志位
  11. uint8_t load_http_config=0;
  12. //get请求 http://gpu.ringzle.com:8082/iot/transmit/getTransmitConfig/DT8pd3ac6h 端口8082
  13. //目前为此处去控制http一次性读入数据大小,应为该处为读入函数
  14. void http_getDemo(void)
  15. {
  16. int datalen;
  17. int ret;
  18. char *http_data=pvPortMalloc(18 * 1024); // 接收数据上限为19K
  19. char *http=pvPortMalloc(50);
  20. sprintf(http,"/iot/transmit/getTransmitConfig/%s",gatewayId);
  21. ret = http_clientGet("gpu.ringzle.com", http, 8082, 0, http_data, &datalen);
  22. if(ret==200) //获取成功
  23. {
  24. // save_config_params(http_data);
  25. load_http_config=1;
  26. }
  27. HTTP_PRINTF("%s", (char *)http_data);
  28. HTTP_PRINTF("\r\n ret=%d datalen=%d\r\n", ret, datalen);
  29. vPortFree(http_data);
  30. vPortFree(http);
  31. http_data = NULL;
  32. http = NULL;
  33. }
  34. /*
  35. *********************************************************************************************************
  36. * 函 数 名: int get_http_config(void)
  37. * 功能说明: 获取http配置的相关参数
  38. * 形 参:无
  39. * 返 回 值: 返回http是否配置 0:没有配置过,1:配置过
  40. *********************************************************************************************************
  41. */
  42. int get_http_config(void)
  43. {
  44. return load_http_config;
  45. }