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.
senml_logging.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 | /* _ __ ____ _ _ |
kpniot | 0:a9259748d982 | 2 | * | |/ / | _ \ | \ | | |
kpniot | 0:a9259748d982 | 3 | * | ' / | |_) | | \| | |
kpniot | 0:a9259748d982 | 4 | * | . \ | __/ | |\ | |
kpniot | 0:a9259748d982 | 5 | * |_|\_\ |_| |_| \_| |
kpniot | 0:a9259748d982 | 6 | * |
kpniot | 0:a9259748d982 | 7 | * (c) 2018 KPN |
kpniot | 0:a9259748d982 | 8 | * License: MIT License. |
kpniot | 0:a9259748d982 | 9 | * Author: Jan Bogaerts |
kpniot | 0:a9259748d982 | 10 | * |
kpniot | 0:a9259748d982 | 11 | * logging |
kpniot | 0:a9259748d982 | 12 | */ |
kpniot | 0:a9259748d982 | 13 | |
kpniot | 0:a9259748d982 | 14 | #ifndef SENMLLOGGING |
kpniot | 0:a9259748d982 | 15 | #define SENMLLOGGING |
kpniot | 0:a9259748d982 | 16 | |
kpniot | 0:a9259748d982 | 17 | #ifdef __MBED__ |
kpniot | 0:a9259748d982 | 18 | #include "mbed.h" |
kpniot | 0:a9259748d982 | 19 | #include "sstream" |
kpniot | 0:a9259748d982 | 20 | #else |
kpniot | 0:a9259748d982 | 21 | #include <stream.h> |
kpniot | 0:a9259748d982 | 22 | #endif |
kpniot | 0:a9259748d982 | 23 | |
kpniot | 0:a9259748d982 | 24 | //contains a referenc to the global logger object assigned to the module |
kpniot | 0:a9259748d982 | 25 | extern Stream* _senml_logger; |
kpniot | 0:a9259748d982 | 26 | |
kpniot | 0:a9259748d982 | 27 | /** |
kpniot | 0:a9259748d982 | 28 | * Assign a stream to the library that can be used to write log information to. |
kpniot | 0:a9259748d982 | 29 | * @param logger a stream object that will be used for logging. |
kpniot | 0:a9259748d982 | 30 | * @returns none |
kpniot | 0:a9259748d982 | 31 | */ |
kpniot | 0:a9259748d982 | 32 | void senMLSetLogger(Stream* logger); |
kpniot | 0:a9259748d982 | 33 | |
kpniot | 0:a9259748d982 | 34 | #ifndef log_debug |
kpniot | 0:a9259748d982 | 35 | #ifdef __MBED__ |
kpniot | 0:a9259748d982 | 36 | #define log_debug(...) if(_senml_logger) {_senml_logger->printf(__VA_ARGS__); _senml_logger->printf("\n\r"); } |
kpniot | 0:a9259748d982 | 37 | #else |
kpniot | 0:a9259748d982 | 38 | #define log_debug(...) if(_senml_logger) _senml_logger->println(__VA_ARGS__) |
kpniot | 0:a9259748d982 | 39 | #endif |
kpniot | 0:a9259748d982 | 40 | #endif |
kpniot | 0:a9259748d982 | 41 | |
kpniot | 0:a9259748d982 | 42 | |
kpniot | 0:a9259748d982 | 43 | #endif // SENMLLOGGING |
kpniot | 0:a9259748d982 | 44 | |
kpniot | 0:a9259748d982 | 45 | |
kpniot | 0:a9259748d982 | 46 | |
kpniot | 0:a9259748d982 | 47 | |
kpniot | 0:a9259748d982 | 48 | |
kpniot | 0:a9259748d982 | 49 | |
kpniot | 0:a9259748d982 | 50 |