sys_http.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "httpclient.h"
  2. #include "string.h"
  3. #include "stdio.h"
  4. uint8_t http_data[6*1024];
  5. //GET请求 http://gpu.ringzle.com/iot/transmit/getTransmitConfig?deviceId=297877563234 端口号8082
  6. void http_getDemo(void)
  7. {
  8. int datalen;
  9. int ret;
  10. memset(http_data, 0, sizeof(http_data));
  11. ret = http_clientGet("gpu.ringzle.com", "/iot/transmit/getTransmitConfig?deviceId=297877563234", 8082, 0, http_data, &datalen);
  12. HTTP_PRINTF("%s", (char *)http_data);
  13. HTTP_PRINTF("\r\n ret=%d datalen=%d\r\n", ret, datalen);
  14. }
  15. char *postData = "{\"bandwidth\":250,\"codeRate\":4700}";
  16. uint8_t postResult[512];
  17. //POST请求 http://gpu.ringzle.com/iot/test/httpTest 端口号8082
  18. void http_postDemo(void)
  19. {
  20. int datalen, ret;
  21. memset(postResult, 0, sizeof(postResult));
  22. // ret = http_clientPost("gpu.ringzle.com", "/iot/test/httpTest", 8082, 0, http_data, 5837, postResult, &datalen);
  23. ret = http_clientPost("gpu.ringzle.com", "/iot/test/httpTest", 8082, 0, (uint8_t *)postData, strlen(postData), postResult, &datalen);
  24. HTTP_PRINTF("%s", (char *)postResult);
  25. HTTP_PRINTF("\r\n ret=%d datalen=%d\r\n", ret, datalen);
  26. }