Guest User

Untitled

a guest
Nov 20th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <ESP8266WiFi.h>
  2. #include <WiFiUdp.h>
  3.  
  4. WiFiUDP graphitesock;
  5.  
  6. #define CARBON_HOST "carbon.hostedgraphite.com"
  7. #define CARBON_PORT 2003
  8. #define PREFIX "your-hosted-graphite-api-key-here"
  9.  
  10. // Place this inside 'main'
  11. // graphitesock.begin(random(40000, 60000));
  12.  
  13. bool graphiteudp(char *host, int port, char *format, ...)
  14. {
  15. char *buf = (char *) malloc(MAX_PACKET_SIZE);
  16. va_list args;
  17. va_start(args, format);
  18. vsnprintf(buf, MAX_PACKET_SIZE, format, args);
  19. va_end(args);
  20.  
  21. graphitesock.beginPacket(host, port);
  22. graphitesock.write(buf);
  23. int retval = graphitesock.endPacket();
  24.  
  25. free(buf);
  26. return retval == 1;
  27. }
Add Comment
Please, Sign In to add comment