lel
Fork of XBeeLib by
Embed:
(wiki syntax)
Show/hide line numbers
FH_IoDataSampleZB.cpp
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 #include "XBeeLib.h" 00014 00015 using namespace XBeeLib; 00016 00017 /** Class constructor */ 00018 FH_IoDataSampeZB::FH_IoDataSampeZB() : FrameHandler(ApiFrame::IoSampleRxZBDM), 00019 io_data_cb(NULL) 00020 { 00021 } 00022 00023 /** Class destructor */ 00024 FH_IoDataSampeZB::~FH_IoDataSampeZB() 00025 { 00026 } 00027 00028 void FH_IoDataSampeZB::register_io_data_cb(io_data_cb_zb_t function) 00029 { 00030 io_data_cb = function; 00031 } 00032 00033 void FH_IoDataSampeZB::unregister_io_data_cb() 00034 { 00035 io_data_cb = NULL; 00036 } 00037 00038 /* ZB RX packet offsets */ 00039 #define ZB_IO_SAMPLE_ADDR16_MSB_OFFSET 8 00040 #define ZB_IO_SAMPLE_ADDR16_LSB_OFFSET 9 00041 #define ZB_IO_SAMPLE_DATA_OFFSET 11 00042 00043 void FH_IoDataSampeZB::process_frame_data(const ApiFrame *const frame) 00044 { 00045 const uint8_t * const datap = frame->get_data();; 00046 00047 /* The caller checks that the type matches, so no need to check it here again */ 00048 if (io_data_cb == NULL) { 00049 return; 00050 } 00051 00052 /* We got an IO packet, decode it... */ 00053 const uint64_t sender64 = addr64_from_uint8_t(datap); 00054 const uint16_t sender16 = ADDR16(datap[ZB_IO_SAMPLE_ADDR16_MSB_OFFSET], datap[ZB_IO_SAMPLE_ADDR16_LSB_OFFSET]); 00055 const RemoteXBeeZB sender = RemoteXBeeZB(sender64, sender16); 00056 const IOSampleZB ioSample = IOSampleZB(&datap[ZB_IO_SAMPLE_DATA_OFFSET], frame->get_data_len() - ZB_IO_SAMPLE_DATA_OFFSET); 00057 00058 io_data_cb(sender, ioSample); 00059 }
Generated on Sat Jul 16 2022 05:30:22 by 1.7.2