discof746 ethernet+lcd+ts2
Dependents: grove_stream_jpa_sd2 grove_stream_jpa_sd2 grove_stream_jpa_sd2-2 grove_stream_jpa_sd2-3
GroveStreams.h@1:e69854e65c88, 2020-08-31 (annotated)
- Committer:
- 38domo
- Date:
- Mon Aug 31 17:50:33 2020 +0000
- Revision:
- 1:e69854e65c88
- Parent:
- 0:8b675b2726b7
- Child:
- 3:494da6893902
no modif in grove stream
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mmills | 0:8b675b2726b7 | 1 | /* |
mmills | 0:8b675b2726b7 | 2 | GroveStreams is a helper class to assist with pushing data into the |
mmills | 0:8b675b2726b7 | 3 | GroveStreams.com IoT platform. |
mmills | 0:8b675b2726b7 | 4 | |
mmills | 0:8b675b2726b7 | 5 | License: |
mmills | 0:8b675b2726b7 | 6 | Copyright (C) 2017 GroveStreams LLC. |
mmills | 0:8b675b2726b7 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); |
mmills | 0:8b675b2726b7 | 8 | you may not use this file except in compliance with the License. |
mmills | 0:8b675b2726b7 | 9 | You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0 |
mmills | 0:8b675b2726b7 | 10 | |
mmills | 0:8b675b2726b7 | 11 | Unless required by applicable law or agreed to in writing, software |
mmills | 0:8b675b2726b7 | 12 | distributed under the License is distributed on an "AS IS" BASIS, |
mmills | 0:8b675b2726b7 | 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mmills | 0:8b675b2726b7 | 14 | See the License for the specific language governing permissions and |
mmills | 0:8b675b2726b7 | 15 | limitations under the License. |
mmills | 0:8b675b2726b7 | 16 | */ |
mmills | 0:8b675b2726b7 | 17 | |
mmills | 0:8b675b2726b7 | 18 | #ifndef GROVESTREAMS_H_ |
mmills | 0:8b675b2726b7 | 19 | #define GROVESTREAMS_H_ |
mmills | 0:8b675b2726b7 | 20 | |
mmills | 0:8b675b2726b7 | 21 | #include "mbed.h" |
mmills | 0:8b675b2726b7 | 22 | #include "EthernetInterface.h" |
mmills | 0:8b675b2726b7 | 23 | #include "NetworkAPI/tcp/socket.hpp" |
mmills | 0:8b675b2726b7 | 24 | #include "LcdDiscoF746NgTracer.h" |
mmills | 0:8b675b2726b7 | 25 | |
38domo | 1:e69854e65c88 | 26 | |
mmills | 0:8b675b2726b7 | 27 | class GroveStreams |
mmills | 0:8b675b2726b7 | 28 | { |
mmills | 0:8b675b2726b7 | 29 | |
mmills | 0:8b675b2726b7 | 30 | protected: |
mmills | 0:8b675b2726b7 | 31 | EthernetInterface _eth; |
mmills | 0:8b675b2726b7 | 32 | LcdDiscoF746NgTracer* _pLcd; |
mmills | 0:8b675b2726b7 | 33 | |
38domo | 1:e69854e65c88 | 34 | //const char* _domain; |
mmills | 0:8b675b2726b7 | 35 | uint16_t _port; |
mmills | 0:8b675b2726b7 | 36 | const char* _apiKey; |
mmills | 0:8b675b2726b7 | 37 | 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 | 38 | |
mmills | 0:8b675b2726b7 | 39 | |
mmills | 0:8b675b2726b7 | 40 | public: |
mmills | 0:8b675b2726b7 | 41 | |
mmills | 0:8b675b2726b7 | 42 | /** Constructor with apiKey and Lcd tracer |
mmills | 0:8b675b2726b7 | 43 | * |
mmills | 0:8b675b2726b7 | 44 | * \param apiKey the secret api_key for your GroveStreams organization |
mmills | 0:8b675b2726b7 | 45 | * \param pLcd optional. Pass NULL or and LCD for tracing |
mmills | 0:8b675b2726b7 | 46 | */ |
mmills | 0:8b675b2726b7 | 47 | GroveStreams(const char* apiKey, LcdDiscoF746NgTracer* pLcd); |
mmills | 0:8b675b2726b7 | 48 | |
mmills | 0:8b675b2726b7 | 49 | /** Constructor with apiKey and Lcd tracer. |
mmills | 0:8b675b2726b7 | 50 | * |
mmills | 0:8b675b2726b7 | 51 | * \param apiKey the secret api_key for your GroveStreams organization |
mmills | 0:8b675b2726b7 | 52 | */ |
mmills | 0:8b675b2726b7 | 53 | GroveStreams(const char* apiKey); |
mmills | 0:8b675b2726b7 | 54 | |
mmills | 0:8b675b2726b7 | 55 | /** Destructor |
mmills | 0:8b675b2726b7 | 56 | * |
mmills | 0:8b675b2726b7 | 57 | */ |
mmills | 0:8b675b2726b7 | 58 | ~GroveStreams(); |
mmills | 0:8b675b2726b7 | 59 | |
mmills | 0:8b675b2726b7 | 60 | protected: |
mmills | 0:8b675b2726b7 | 61 | int init(const char* apiKey, LcdDiscoF746NgTracer* pLcd); |
mmills | 0:8b675b2726b7 | 62 | void printf(const char* format, ...); |
mmills | 0:8b675b2726b7 | 63 | |
mmills | 0:8b675b2726b7 | 64 | public: |
mmills | 0:8b675b2726b7 | 65 | |
mmills | 0:8b675b2726b7 | 66 | /** Send sample data to GroveStreams. Attempts to restore dropped ethernet |
mmills | 0:8b675b2726b7 | 67 | * connections |
mmills | 0:8b675b2726b7 | 68 | * |
mmills | 0:8b675b2726b7 | 69 | * \param componentId The ID of the component to put the samples into |
mmills | 0:8b675b2726b7 | 70 | * \param samples a string that is URL Encoded and contains all of the |
mmills | 0:8b675b2726b7 | 71 | * samples. Place an ampersand at the beggining of each sample substring. |
mmills | 0:8b675b2726b7 | 72 | * The substring is &streamId=value. |
mmills | 0:8b675b2726b7 | 73 | * Example: &temp=6&eres=78.231&on=true&position=on+ground |
mmills | 0:8b675b2726b7 | 74 | * \return 0 on success |
mmills | 0:8b675b2726b7 | 75 | */ |
mmills | 0:8b675b2726b7 | 76 | unsigned long send(const char* componentId, const char* samples); |
38domo | 1:e69854e65c88 | 77 | unsigned long sendJPA(const char* componentId, const char* samples); |
38domo | 1:e69854e65c88 | 78 | unsigned long sendInitDatasJPA(const char* componentId, const char* samples); |
mmills | 0:8b675b2726b7 | 79 | |
mmills | 0:8b675b2726b7 | 80 | /** Send sample data to GroveStreams. Attempts to restore dropped ethernet |
mmills | 0:8b675b2726b7 | 81 | * connections |
mmills | 0:8b675b2726b7 | 82 | * |
mmills | 0:8b675b2726b7 | 83 | * \param componentId The ID of the component to put the samples into |
mmills | 0:8b675b2726b7 | 84 | * \param samples a string that is URL Encoded and contains all of the |
mmills | 0:8b675b2726b7 | 85 | * samples. Place an ampersand at the beggining of each sample substring. |
mmills | 0:8b675b2726b7 | 86 | * The substring is &streamId=value. |
mmills | 0:8b675b2726b7 | 87 | * Example: &temp=6&eres=78.231&on=true&position=on+ground |
mmills | 0:8b675b2726b7 | 88 | * \param resultBuffer a string that will contain the http result body |
mmills | 0:8b675b2726b7 | 89 | * \param resultBufferSize the size of the result buffer |
mmills | 0:8b675b2726b7 | 90 | * \return 0 on success |
mmills | 0:8b675b2726b7 | 91 | */ |
mmills | 0:8b675b2726b7 | 92 | unsigned long send(const char* componentId, const char* samples, char* resultBuffer, size_t resultBufferSize); |
mmills | 0:8b675b2726b7 | 93 | |
mmills | 0:8b675b2726b7 | 94 | /** Send sample data to GroveStreams. Attempts to restore dropped ethernet |
mmills | 0:8b675b2726b7 | 95 | * connections |
mmills | 0:8b675b2726b7 | 96 | * |
mmills | 0:8b675b2726b7 | 97 | * \param componentId The ID of the component to put the samples into |
mmills | 0:8b675b2726b7 | 98 | * \param samples a string that is URL Encoded and contains all of the |
mmills | 0:8b675b2726b7 | 99 | * samples. Place an ampersand at the beggining of each sample substring. |
mmills | 0:8b675b2726b7 | 100 | * The substring is &streamId=value. |
mmills | 0:8b675b2726b7 | 101 | * Example: &temp=6&eres=78.231&on=true&position=on+ground |
mmills | 0:8b675b2726b7 | 102 | * \param componentName optional (NULL). the name assigned to a newly created component. |
mmills | 0:8b675b2726b7 | 103 | * \param compTmplId optional (NULL). the component template ID to be used for creating a |
mmills | 0:8b675b2726b7 | 104 | * new component |
mmills | 0:8b675b2726b7 | 105 | * \param resultBuffer a string that will contain the http result body |
mmills | 0:8b675b2726b7 | 106 | * \param resultBufferSize the size of the result buffer |
mmills | 0:8b675b2726b7 | 107 | * \return 0 on success |
mmills | 0:8b675b2726b7 | 108 | */ |
mmills | 0:8b675b2726b7 | 109 | unsigned long send(const char* componentId, const char* samples, const char* componentName, const char* compTmplId, char* resultBuffer, size_t resultBufferSize); |
38domo | 1:e69854e65c88 | 110 | unsigned long sendJPA(const char* componentId, const char* samples, const char* componentName, const char* compTmplId, char* resultBuffer, size_t resultBufferSize); |
38domo | 1:e69854e65c88 | 111 | unsigned long sendInitDatasJPA(const char* componentId, const char* samples, const char* componentName, const char* compTmplId, char* resultBuffer, size_t resultBufferSize); |
38domo | 1:e69854e65c88 | 112 | |
mmills | 0:8b675b2726b7 | 113 | /** Send sample data to GroveStreams. Does not attempt to restore dropped |
mmills | 0:8b675b2726b7 | 114 | * ethernet connections. |
mmills | 0:8b675b2726b7 | 115 | * |
mmills | 0:8b675b2726b7 | 116 | * \param componentId The ID of the component to put the samples into |
mmills | 0:8b675b2726b7 | 117 | * \param samples a string that is URL Encoded and contains all of the |
mmills | 0:8b675b2726b7 | 118 | * samples. Place an ampersand at the beggining of each sample substring. |
mmills | 0:8b675b2726b7 | 119 | * The substring is &streamId=value. |
mmills | 0:8b675b2726b7 | 120 | * Example: &temp=6&eres=78.231&on=true&position=on+ground |
mmills | 0:8b675b2726b7 | 121 | * \param componentName optional (NULL). the name assigned to a newly created component. |
mmills | 0:8b675b2726b7 | 122 | * \param compTmplId optional (NULL). the component template ID to be used for creating a |
mmills | 0:8b675b2726b7 | 123 | * new component |
mmills | 0:8b675b2726b7 | 124 | * \param resultBuffer a string that will contain the http result body |
mmills | 0:8b675b2726b7 | 125 | * \param resultBufferSize the size of the result buffer |
mmills | 0:8b675b2726b7 | 126 | * \return 0 on success |
mmills | 0:8b675b2726b7 | 127 | */ |
mmills | 0:8b675b2726b7 | 128 | unsigned long sendNoRetry(const char* componentId, const char* samples, const char* componentName, const char* compTmplId, char* resultBuffer, size_t resultBufferSize); |
38domo | 1:e69854e65c88 | 129 | unsigned long sendNoRetryJPA(const char* componentId, const char* samples, const char* componentName, const char* compTmplId, char* resultBuffer, size_t resultBufferSize); |
38domo | 1:e69854e65c88 | 130 | unsigned long sendNoRetryInitDatasJPA(const char* componentId, const char* samples, const char* componentName, const char* compTmplId, char* resultBuffer, size_t resultBufferSize); |
mmills | 0:8b675b2726b7 | 131 | |
mmills | 0:8b675b2726b7 | 132 | /** Starts ethernet. |
mmills | 0:8b675b2726b7 | 133 | * Stops ethernet if it is running before starting it. |
mmills | 0:8b675b2726b7 | 134 | * \return 0 on success |
mmills | 0:8b675b2726b7 | 135 | */ |
mmills | 0:8b675b2726b7 | 136 | int startEthernet(); |
mmills | 0:8b675b2726b7 | 137 | |
mmills | 0:8b675b2726b7 | 138 | /** Get the MAC address of your Ethernet interface |
mmills | 0:8b675b2726b7 | 139 | * \return a pointer to a string containing the MAC address |
mmills | 0:8b675b2726b7 | 140 | */ |
mmills | 0:8b675b2726b7 | 141 | const char* getMACAddress(); |
mmills | 0:8b675b2726b7 | 142 | |
mmills | 0:8b675b2726b7 | 143 | }; |
mmills | 0:8b675b2726b7 | 144 | |
38domo | 1:e69854e65c88 | 145 | #endif /* GROVESTREAMS_H_ */ |