Vergil Cola
/
MQTTGatewayK64
Fork of my MQTTGateway
XbeeMonitor/XBeeLib/IO/IOSampleDM.h@0:f1d3878b8dd9, 2017-04-08 (annotated)
- Committer:
- vpcola
- Date:
- Sat Apr 08 14:45:51 2017 +0000
- Revision:
- 0:f1d3878b8dd9
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vpcola | 0:f1d3878b8dd9 | 1 | /** |
vpcola | 0:f1d3878b8dd9 | 2 | * Copyright (c) 2015 Digi International Inc., |
vpcola | 0:f1d3878b8dd9 | 3 | * All rights not expressly granted are reserved. |
vpcola | 0:f1d3878b8dd9 | 4 | * |
vpcola | 0:f1d3878b8dd9 | 5 | * This Source Code Form is subject to the terms of the Mozilla Public |
vpcola | 0:f1d3878b8dd9 | 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
vpcola | 0:f1d3878b8dd9 | 7 | * You can obtain one at http://mozilla.org/MPL/2.0/. |
vpcola | 0:f1d3878b8dd9 | 8 | * |
vpcola | 0:f1d3878b8dd9 | 9 | * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343 |
vpcola | 0:f1d3878b8dd9 | 10 | * ======================================================================= |
vpcola | 0:f1d3878b8dd9 | 11 | */ |
vpcola | 0:f1d3878b8dd9 | 12 | |
vpcola | 0:f1d3878b8dd9 | 13 | #ifndef _IO_IOSAMPLEDM_H_ |
vpcola | 0:f1d3878b8dd9 | 14 | #define _IO_IOSAMPLEDM_H_ |
vpcola | 0:f1d3878b8dd9 | 15 | |
vpcola | 0:f1d3878b8dd9 | 16 | #define MAX_IO_SAMPLE_DM_LEN (2 + 2 * 5) |
vpcola | 0:f1d3878b8dd9 | 17 | |
vpcola | 0:f1d3878b8dd9 | 18 | namespace XBeeLib { |
vpcola | 0:f1d3878b8dd9 | 19 | |
vpcola | 0:f1d3878b8dd9 | 20 | /** Class to handle the incoming IO Data Samples in ZigBee modules */ |
vpcola | 0:f1d3878b8dd9 | 21 | class IOSampleDM { |
vpcola | 0:f1d3878b8dd9 | 22 | public: |
vpcola | 0:f1d3878b8dd9 | 23 | /** Class constructor |
vpcola | 0:f1d3878b8dd9 | 24 | * @param raw_data The IO Sample data, as returned by an "IS" command response or in the IoSampleRxZBDM (0x92) frames |
vpcola | 0:f1d3878b8dd9 | 25 | * @param size size (in bytes) of raw_data. |
vpcola | 0:f1d3878b8dd9 | 26 | */ |
vpcola | 0:f1d3878b8dd9 | 27 | IOSampleDM(const uint8_t* const raw_data = NULL, size_t size = 0); |
vpcola | 0:f1d3878b8dd9 | 28 | |
vpcola | 0:f1d3878b8dd9 | 29 | /** Class destructor */ |
vpcola | 0:f1d3878b8dd9 | 30 | ~IOSampleDM(); |
vpcola | 0:f1d3878b8dd9 | 31 | |
vpcola | 0:f1d3878b8dd9 | 32 | /** get_dio - read the value of a DIO configured as digital input |
vpcola | 0:f1d3878b8dd9 | 33 | * |
vpcola | 0:f1d3878b8dd9 | 34 | * @param line DIO line being read |
vpcola | 0:f1d3878b8dd9 | 35 | * @param val pointer where the DIO value read will be stored |
vpcola | 0:f1d3878b8dd9 | 36 | * @returns |
vpcola | 0:f1d3878b8dd9 | 37 | * Success if the operation was successful, |
vpcola | 0:f1d3878b8dd9 | 38 | * Failure otherwise |
vpcola | 0:f1d3878b8dd9 | 39 | */ |
vpcola | 0:f1d3878b8dd9 | 40 | RadioStatus get_dio(XBeeDM::IoLine line, DioVal* const dio_value) const; |
vpcola | 0:f1d3878b8dd9 | 41 | |
vpcola | 0:f1d3878b8dd9 | 42 | /** get_adc - read the value of the espcified ADC line |
vpcola | 0:f1d3878b8dd9 | 43 | * |
vpcola | 0:f1d3878b8dd9 | 44 | * @param line ADC line being read |
vpcola | 0:f1d3878b8dd9 | 45 | * @param val pointer where the value read from the ADC will be stored |
vpcola | 0:f1d3878b8dd9 | 46 | * @returns |
vpcola | 0:f1d3878b8dd9 | 47 | * Success if the operation was successful, |
vpcola | 0:f1d3878b8dd9 | 48 | * Failure otherwise |
vpcola | 0:f1d3878b8dd9 | 49 | */ |
vpcola | 0:f1d3878b8dd9 | 50 | RadioStatus get_adc(XBeeDM::IoLine line, uint16_t* const val) const; |
vpcola | 0:f1d3878b8dd9 | 51 | |
vpcola | 0:f1d3878b8dd9 | 52 | /** is_valid - checks if the IOSampleDM object has at least one DIO or ADC sample. |
vpcola | 0:f1d3878b8dd9 | 53 | * @returns true if valid, false otherwise |
vpcola | 0:f1d3878b8dd9 | 54 | */ |
vpcola | 0:f1d3878b8dd9 | 55 | inline bool is_valid() |
vpcola | 0:f1d3878b8dd9 | 56 | { |
vpcola | 0:f1d3878b8dd9 | 57 | return _digital_mask != 0 || _analog_mask != 0; |
vpcola | 0:f1d3878b8dd9 | 58 | } |
vpcola | 0:f1d3878b8dd9 | 59 | |
vpcola | 0:f1d3878b8dd9 | 60 | protected: |
vpcola | 0:f1d3878b8dd9 | 61 | uint16_t _digital_mask; |
vpcola | 0:f1d3878b8dd9 | 62 | uint8_t _analog_mask; |
vpcola | 0:f1d3878b8dd9 | 63 | uint8_t _sampled_data[MAX_IO_SAMPLE_DM_LEN]; |
vpcola | 0:f1d3878b8dd9 | 64 | uint8_t _sampled_data_size; |
vpcola | 0:f1d3878b8dd9 | 65 | |
vpcola | 0:f1d3878b8dd9 | 66 | inline uint16_t get_digital_channels(void) const; |
vpcola | 0:f1d3878b8dd9 | 67 | }; |
vpcola | 0:f1d3878b8dd9 | 68 | |
vpcola | 0:f1d3878b8dd9 | 69 | } /* namespace XBeeLib */ |
vpcola | 0:f1d3878b8dd9 | 70 | |
vpcola | 0:f1d3878b8dd9 | 71 | #endif /* _IO_IOSAMPLEDM_H_ */ |