The KPN SenML library helps you create and parse senml documents in both json and cbor format. The library can be used for sending sensor data and receiving actuator commands.
Fork of kpn_senml by
senml_JsonListener.h@0:a9259748d982, 2018-05-19 (annotated)
- Committer:
- kpniot
- Date:
- Sat May 19 17:35:20 2018 +0000
- Revision:
- 0:a9259748d982
first commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kpniot | 0:a9259748d982 | 1 | /**The MIT License (MIT) |
kpniot | 0:a9259748d982 | 2 | |
kpniot | 0:a9259748d982 | 3 | Copyright (c) 2015 by Daniel Eichhorn |
kpniot | 0:a9259748d982 | 4 | |
kpniot | 0:a9259748d982 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy |
kpniot | 0:a9259748d982 | 6 | of this software and associated documentation files (the "Software"), to deal |
kpniot | 0:a9259748d982 | 7 | in the Software without restriction, including without limitation the rights |
kpniot | 0:a9259748d982 | 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
kpniot | 0:a9259748d982 | 9 | copies of the Software, and to permit persons to whom the Software is |
kpniot | 0:a9259748d982 | 10 | furnished to do so, subject to the following conditions: |
kpniot | 0:a9259748d982 | 11 | |
kpniot | 0:a9259748d982 | 12 | The above copyright notice and this permission notice shall be included in all |
kpniot | 0:a9259748d982 | 13 | copies or substantial portions of the Software. |
kpniot | 0:a9259748d982 | 14 | |
kpniot | 0:a9259748d982 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
kpniot | 0:a9259748d982 | 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
kpniot | 0:a9259748d982 | 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
kpniot | 0:a9259748d982 | 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
kpniot | 0:a9259748d982 | 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
kpniot | 0:a9259748d982 | 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
kpniot | 0:a9259748d982 | 21 | SOFTWARE. |
kpniot | 0:a9259748d982 | 22 | |
kpniot | 0:a9259748d982 | 23 | See more at http://blog.squix.ch and https://github.com/squix78/json-streaming-parser |
kpniot | 0:a9259748d982 | 24 | */ |
kpniot | 0:a9259748d982 | 25 | |
kpniot | 0:a9259748d982 | 26 | #ifndef SENMLJSONLISTENER |
kpniot | 0:a9259748d982 | 27 | #define SENMLJSONLISTENER |
kpniot | 0:a9259748d982 | 28 | |
kpniot | 0:a9259748d982 | 29 | #ifdef __MBED__ |
kpniot | 0:a9259748d982 | 30 | #include "mbed.h" |
kpniot | 0:a9259748d982 | 31 | #include <string> |
kpniot | 0:a9259748d982 | 32 | using namespace std; |
kpniot | 0:a9259748d982 | 33 | #define String string |
kpniot | 0:a9259748d982 | 34 | #else |
kpniot | 0:a9259748d982 | 35 | #include <Arduino.h> |
kpniot | 0:a9259748d982 | 36 | #endif |
kpniot | 0:a9259748d982 | 37 | |
kpniot | 0:a9259748d982 | 38 | /** |
kpniot | 0:a9259748d982 | 39 | * Internal helper class for parsing json data. |
kpniot | 0:a9259748d982 | 40 | */ |
kpniot | 0:a9259748d982 | 41 | class JsonListener { |
kpniot | 0:a9259748d982 | 42 | private: |
kpniot | 0:a9259748d982 | 43 | |
kpniot | 0:a9259748d982 | 44 | public: |
kpniot | 0:a9259748d982 | 45 | |
kpniot | 0:a9259748d982 | 46 | //virtual void startDocument() = 0; |
kpniot | 0:a9259748d982 | 47 | |
kpniot | 0:a9259748d982 | 48 | virtual void key(String key) = 0; |
kpniot | 0:a9259748d982 | 49 | |
kpniot | 0:a9259748d982 | 50 | virtual void value(String value) = 0; |
kpniot | 0:a9259748d982 | 51 | |
kpniot | 0:a9259748d982 | 52 | //virtual void endArray() = 0; |
kpniot | 0:a9259748d982 | 53 | |
kpniot | 0:a9259748d982 | 54 | //virtual void endObject() = 0; |
kpniot | 0:a9259748d982 | 55 | |
kpniot | 0:a9259748d982 | 56 | //virtual void endDocument() = 0; |
kpniot | 0:a9259748d982 | 57 | |
kpniot | 0:a9259748d982 | 58 | //virtual void startArray() = 0; |
kpniot | 0:a9259748d982 | 59 | |
kpniot | 0:a9259748d982 | 60 | //virtual void startObject() = 0; |
kpniot | 0:a9259748d982 | 61 | |
kpniot | 0:a9259748d982 | 62 | }; |
kpniot | 0:a9259748d982 | 63 | |
kpniot | 0:a9259748d982 | 64 | #endif |
kpniot | 0:a9259748d982 | 65 | |
kpniot | 0:a9259748d982 | 66 | |
kpniot | 0:a9259748d982 | 67 | |
kpniot | 0:a9259748d982 | 68 | |
kpniot | 0:a9259748d982 | 69 | |
kpniot | 0:a9259748d982 | 70 | |
kpniot | 0:a9259748d982 | 71 | |
kpniot | 0:a9259748d982 | 72 |