mbed based IoT Gateway More details http://blog.thiseldo.co.uk/wp-filez/IoTGateway.pdf
Dependencies: NetServices FatFileSystem csv_parser mbed MQTTClient RF12B DNSResolver SDFileSystem
Payloads/PayloadV1.cpp@0:a29a0225f203, 2012-04-02 (annotated)
- Committer:
- SomeRandomBloke
- Date:
- Mon Apr 02 22:05:20 2012 +0000
- Revision:
- 0:a29a0225f203
Initial version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
SomeRandomBloke | 0:a29a0225f203 | 1 | /** IoT Gateway RFM12B payload V1 format handling |
SomeRandomBloke | 0:a29a0225f203 | 2 | * |
SomeRandomBloke | 0:a29a0225f203 | 3 | * @author Andrew Lindsay |
SomeRandomBloke | 0:a29a0225f203 | 4 | * |
SomeRandomBloke | 0:a29a0225f203 | 5 | * @section LICENSE |
SomeRandomBloke | 0:a29a0225f203 | 6 | * |
SomeRandomBloke | 0:a29a0225f203 | 7 | * Copyright (c) 2012 Andrew Lindsay (andrew [at] thiseldo [dot] co [dot] uk) |
SomeRandomBloke | 0:a29a0225f203 | 8 | * |
SomeRandomBloke | 0:a29a0225f203 | 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
SomeRandomBloke | 0:a29a0225f203 | 10 | * of this software and associated documentation files (the "Software"), to deal |
SomeRandomBloke | 0:a29a0225f203 | 11 | * in the Software without restriction, including without limitation the rights |
SomeRandomBloke | 0:a29a0225f203 | 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
SomeRandomBloke | 0:a29a0225f203 | 13 | * copies of the Software, and to permit persons to whom the Software is |
SomeRandomBloke | 0:a29a0225f203 | 14 | * furnished to do so, subject to the following conditions: |
SomeRandomBloke | 0:a29a0225f203 | 15 | |
SomeRandomBloke | 0:a29a0225f203 | 16 | * The above copyright notice and this permission notice shall be included in |
SomeRandomBloke | 0:a29a0225f203 | 17 | * all copies or substantial portions of the Software. |
SomeRandomBloke | 0:a29a0225f203 | 18 | * |
SomeRandomBloke | 0:a29a0225f203 | 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
SomeRandomBloke | 0:a29a0225f203 | 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
SomeRandomBloke | 0:a29a0225f203 | 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
SomeRandomBloke | 0:a29a0225f203 | 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
SomeRandomBloke | 0:a29a0225f203 | 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
SomeRandomBloke | 0:a29a0225f203 | 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
SomeRandomBloke | 0:a29a0225f203 | 25 | * THE SOFTWARE. |
SomeRandomBloke | 0:a29a0225f203 | 26 | * |
SomeRandomBloke | 0:a29a0225f203 | 27 | * @section DESCRIPTION |
SomeRandomBloke | 0:a29a0225f203 | 28 | * |
SomeRandomBloke | 0:a29a0225f203 | 29 | * |
SomeRandomBloke | 0:a29a0225f203 | 30 | */ |
SomeRandomBloke | 0:a29a0225f203 | 31 | |
SomeRandomBloke | 0:a29a0225f203 | 32 | #include "mbed.h" |
SomeRandomBloke | 0:a29a0225f203 | 33 | #include "RF12B.h" |
SomeRandomBloke | 0:a29a0225f203 | 34 | #include "PayloadV1.h" |
SomeRandomBloke | 0:a29a0225f203 | 35 | |
SomeRandomBloke | 0:a29a0225f203 | 36 | |
SomeRandomBloke | 0:a29a0225f203 | 37 | // Constructors for a new V1 payload |
SomeRandomBloke | 0:a29a0225f203 | 38 | PayloadV1::PayloadV1( ) : PayloadDef() {} |
SomeRandomBloke | 0:a29a0225f203 | 39 | PayloadV1::PayloadV1( uint8_t *pptr, short plen ): PayloadDef( pptr, plen ) { |
SomeRandomBloke | 0:a29a0225f203 | 40 | readingCount = (short) (payloadBuffer[2] - 1) / 3; |
SomeRandomBloke | 0:a29a0225f203 | 41 | } |
SomeRandomBloke | 0:a29a0225f203 | 42 | |
SomeRandomBloke | 0:a29a0225f203 | 43 | short PayloadV1::numReadings() { |
SomeRandomBloke | 0:a29a0225f203 | 44 | return readingCount; |
SomeRandomBloke | 0:a29a0225f203 | 45 | } |
SomeRandomBloke | 0:a29a0225f203 | 46 | |
SomeRandomBloke | 0:a29a0225f203 | 47 | int PayloadV1::reading( short readingNum ) { |
SomeRandomBloke | 0:a29a0225f203 | 48 | short reading = (payloadBuffer[6 + (readingNum * 3)] << 8) + payloadBuffer[5 + (readingNum * 3)]; |
SomeRandomBloke | 0:a29a0225f203 | 49 | return (int)(reading); |
SomeRandomBloke | 0:a29a0225f203 | 50 | } |
SomeRandomBloke | 0:a29a0225f203 | 51 | |
SomeRandomBloke | 0:a29a0225f203 | 52 | short PayloadV1::sensorId( short readingNum ) { |
SomeRandomBloke | 0:a29a0225f203 | 53 | return (short)(payloadBuffer[4 + (readingNum * 3)]); |
SomeRandomBloke | 0:a29a0225f203 | 54 | } |