Fork of my original MQTTGateway

Dependencies:   mbed-http

Committer:
vpcola
Date:
Sat Apr 08 14:43:14 2017 +0000
Revision:
0:a1734fe1ec4b
Initial commit

Who changed what in which revision?

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