XBee modules

Dependencies:   DigiLogger

Fork of XBeeLib by Digi International Inc.

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers IOSampleZB.h Source File

IOSampleZB.h

00001 /**
00002  * Copyright (c) 2015 Digi International Inc.,
00003  * All rights not expressly granted are reserved.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
00007  * You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
00010  * =======================================================================
00011  */
00012 
00013 #ifndef _IO_IOSAMPLEZB_H_
00014 #define _IO_IOSAMPLEZB_H_
00015 
00016 #define MAX_IO_SAMPLE_ZB_LEN   (2 + 2 * 5)
00017 
00018 namespace XBeeLib {
00019 
00020 /** Class to handle the incoming IO Data Samples in ZigBee modules */
00021 class IOSampleZB {
00022     public:
00023         /** Class constructor
00024          *  @param raw_data The IO Sample data, as returned by an "IS" command response or in the IoSampleRxZBDM (0x92) frames
00025          *  @param size size (in bytes) of raw_data.
00026          */
00027         IOSampleZB(const uint8_t* const raw_data = NULL, size_t size = 0);
00028 
00029         /** Class destructor */
00030         ~IOSampleZB();
00031 
00032         /** get_dio - read the value of a DIO configured as digital input
00033          *
00034          *  @param line DIO line being read
00035          *  @param val pointer where the DIO value read will be stored
00036          *  @returns
00037          *     Success if the operation was successful,
00038          *     Failure otherwise
00039          */
00040         RadioStatus get_dio(XBeeZB::IoLine line, DioVal* const dio_value) const;
00041 
00042         /** get_adc - read the value of the espcified ADC line
00043          *
00044          *  @param line ADC line being read
00045          *  @param val pointer where the value read from the ADC will be stored
00046          *  @returns
00047          *     Success if the operation was successful,
00048          *     Failure otherwise
00049          */
00050         RadioStatus get_adc(XBeeZB::IoLine line, uint16_t* const val) const;
00051 
00052         /** is_valid - checks if the IOSampleZB object has at least one DIO or ADC sample.
00053          *  @returns true if valid, false otherwise
00054          */
00055         inline bool is_valid()
00056         {
00057             return _digital_mask != 0 || _analog_mask != 0;
00058         }
00059 
00060     protected:
00061         uint16_t _digital_mask;
00062         uint8_t _analog_mask;
00063         uint8_t _sampled_data[MAX_IO_SAMPLE_ZB_LEN];
00064         uint8_t _sampled_data_size;
00065 
00066         inline uint16_t get_digital_channels(void) const;
00067 };
00068 
00069 }   /* namespace XBeeLib */
00070 
00071 #endif /* _IO_IOSAMPLEZB_H_ */