discof746 ethernet+lcd+ts2

Dependents:   grove_stream_jpa_sd2 grove_stream_jpa_sd2 grove_stream_jpa_sd2-2 grove_stream_jpa_sd2-3

Committer:
38domo
Date:
Wed Jan 13 19:51:28 2021 +0000
Revision:
3:494da6893902
Parent:
1:e69854e65c88
update grove sreams lib

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mmills 0:8b675b2726b7 1 /*
38domo 3:494da6893902 2 GroveStreams is a helper class to assist with pushing data into the GroveStreams.com IoT platform.
mmills 0:8b675b2726b7 3 */
mmills 0:8b675b2726b7 4 #ifndef GROVESTREAMS_H_
mmills 0:8b675b2726b7 5 #define GROVESTREAMS_H_
mmills 0:8b675b2726b7 6 #include "mbed.h"
mmills 0:8b675b2726b7 7 #include "EthernetInterface.h"
mmills 0:8b675b2726b7 8 #include "NetworkAPI/tcp/socket.hpp"
mmills 0:8b675b2726b7 9 #include "LcdDiscoF746NgTracer.h"
mmills 0:8b675b2726b7 10 class GroveStreams
mmills 0:8b675b2726b7 11 {
mmills 0:8b675b2726b7 12 protected:
mmills 0:8b675b2726b7 13 EthernetInterface _eth;
mmills 0:8b675b2726b7 14 LcdDiscoF746NgTracer* _pLcd;
38domo 1:e69854e65c88 15 //const char* _domain;
mmills 0:8b675b2726b7 16 uint16_t _port;
mmills 0:8b675b2726b7 17 const char* _apiKey;
mmills 0:8b675b2726b7 18 const char* _myIPAddress; //Don't Change. Set below from DHCP. Needed by GroveStreams to verify that a device is not uploading more than once every 10s.
mmills 0:8b675b2726b7 19 public:
mmills 0:8b675b2726b7 20 /** Constructor with apiKey and Lcd tracer
38domo 3:494da6893902 21 * \param apiKey the secret api_key for your GroveStreams organization \param pLcd optional. Pass NULL or and LCD for tracing
mmills 0:8b675b2726b7 22 */
mmills 0:8b675b2726b7 23 GroveStreams(const char* apiKey, LcdDiscoF746NgTracer* pLcd);
38domo 3:494da6893902 24 /** Constructor with apiKey and Lcd tracer. * \param apiKey the secret api_key for your GroveStreams organization */
38domo 3:494da6893902 25 GroveStreams(const char* apiKey);
38domo 3:494da6893902 26 /** Destructor * */
mmills 0:8b675b2726b7 27 ~GroveStreams();
mmills 0:8b675b2726b7 28 protected:
mmills 0:8b675b2726b7 29 int init(const char* apiKey, LcdDiscoF746NgTracer* pLcd);
mmills 0:8b675b2726b7 30 void printf(const char* format, ...);
mmills 0:8b675b2726b7 31 public:
38domo 3:494da6893902 32 /** Send sample data to GroveStreams. Attempts to restore dropped ethernet connections
38domo 3:494da6893902 33 * \param componentId The ID of the component to put the samples into \param samples a string that is URL Encoded and contains all of the
mmills 0:8b675b2726b7 34 * samples. Place an ampersand at the beggining of each sample substring.
mmills 0:8b675b2726b7 35 * The substring is &streamId=value.
38domo 3:494da6893902 36 * Example: &temp=6&amperes=78.231&on=true&position=on+ground \return 0 on success */
mmills 0:8b675b2726b7 37 unsigned long send(const char* componentId, const char* samples);
38domo 1:e69854e65c88 38 unsigned long sendJPA(const char* componentId, const char* samples);
38domo 3:494da6893902 39 unsigned long sendInitDatasJPA(const char* componentId, const char* samples);
38domo 3:494da6893902 40 /** Send sample data to GroveStreams. Attempts to restore dropped ethernet connections *
mmills 0:8b675b2726b7 41 * \param componentId The ID of the component to put the samples into
38domo 3:494da6893902 42 * \param samples a string that is URL Encoded and contains all of the samples. Place an ampersand at the beggining of each sample substring.
38domo 3:494da6893902 43 * The substring is &streamId=value.
38domo 3:494da6893902 44 * Example: &temp=6&amperes=78.231&on=true&position=on+ground * \param resultBuffer a string that will contain the http result body
38domo 3:494da6893902 45 * \param resultBufferSize the size of the result buffer * \return 0 on success */
38domo 3:494da6893902 46 unsigned long send(const char* componentId, const char* samples, char* resultBuffer, size_t resultBufferSize);
38domo 3:494da6893902 47 /** Send sample data to GroveStreams. Attempts to restore dropped ethernet connections *
38domo 3:494da6893902 48 * \param componentId The ID of the component to put the samples into * \param samples a string that is URL Encoded and contains all of the
mmills 0:8b675b2726b7 49 * samples. Place an ampersand at the beggining of each sample substring.
mmills 0:8b675b2726b7 50 * The substring is &streamId=value.
38domo 3:494da6893902 51 * Example: &temp=6&amperes=78.231&on=true&position=on+ground * \param componentName optional (NULL). the name assigned to a newly created component.
38domo 3:494da6893902 52 * \param compTmplId optional (NULL). the component template ID to be used for creating a new component
38domo 3:494da6893902 53 * \param resultBuffer a string that will contain the http result body* \param resultBufferSize the size of the result buffer
38domo 3:494da6893902 54 * \return 0 on success */
38domo 3:494da6893902 55 unsigned long send(const char* componentId, const char* samples, const char* componentName, const char* compTmplId, char* resultBuffer, size_t resultBufferSize);
38domo 3:494da6893902 56 unsigned long sendJPA(const char* componentId, const char* samples, const char* componentName, const char* compTmplId, char* resultBuffer, size_t resultBufferSize);
38domo 3:494da6893902 57 unsigned long sendInitDatasJPA(const char* componentId, const char* samples, const char* componentName, const char* compTmplId, char* resultBuffer, size_t resultBufferSize);
38domo 3:494da6893902 58 /** Send sample data to GroveStreams. Does not attempt to restore dropped ethernet connections. *
mmills 0:8b675b2726b7 59 * \param componentId The ID of the component to put the samples into
mmills 0:8b675b2726b7 60 * \param samples a string that is URL Encoded and contains all of the
mmills 0:8b675b2726b7 61 * samples. Place an ampersand at the beggining of each sample substring.
mmills 0:8b675b2726b7 62 * The substring is &streamId=value.
mmills 0:8b675b2726b7 63 * Example: &temp=6&amperes=78.231&on=true&position=on+ground
mmills 0:8b675b2726b7 64 * \param componentName optional (NULL). the name assigned to a newly created component.
38domo 3:494da6893902 65 * \param compTmplId optional (NULL). the component template ID to be used for creating a * new component
38domo 3:494da6893902 66 * \param resultBuffer a string that will contain the http result body * \param resultBufferSize the size of the result buffer
38domo 3:494da6893902 67 * \return 0 on success */
mmills 0:8b675b2726b7 68 unsigned long sendNoRetry(const char* componentId, const char* samples, const char* componentName, const char* compTmplId, char* resultBuffer, size_t resultBufferSize);
38domo 1:e69854e65c88 69 unsigned long sendNoRetryJPA(const char* componentId, const char* samples, const char* componentName, const char* compTmplId, char* resultBuffer, size_t resultBufferSize);
38domo 1:e69854e65c88 70 unsigned long sendNoRetryInitDatasJPA(const char* componentId, const char* samples, const char* componentName, const char* compTmplId, char* resultBuffer, size_t resultBufferSize);
38domo 3:494da6893902 71 /** Starts ethernet. * Stops ethernet if it is running before starting it. * \return 0 on success */
38domo 3:494da6893902 72 int startEthernet();
38domo 3:494da6893902 73 /** Get the MAC address of your Ethernet interface -return a pointer to a string containing the MAC address */
mmills 0:8b675b2726b7 74 const char* getMACAddress();
mmills 0:8b675b2726b7 75 };
38domo 1:e69854e65c88 76 #endif /* GROVESTREAMS_H_ */