Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of XBeeLib by
FH_RxPacketZB.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 "FH_RxPacketZB.h" 00014 00015 using namespace XBeeLib; 00016 00017 /** Class constructor */ 00018 FH_RxPacketZB::FH_RxPacketZB() : FrameHandler(ApiFrame::RxPacketAO0), receive_cb(NULL) 00019 { 00020 } 00021 00022 /** Class destructor */ 00023 FH_RxPacketZB::~FH_RxPacketZB() 00024 { 00025 } 00026 00027 void FH_RxPacketZB::register_receive_cb(receive_zb_cb_t function) 00028 { 00029 receive_cb = function; 00030 } 00031 00032 void FH_RxPacketZB::unregister_receive_cb(void) 00033 { 00034 receive_cb = NULL; 00035 } 00036 00037 /* ZB RX packet offsets */ 00038 #define ZB_RX_ADDR16_MSB_OFFSET 8 00039 #define ZB_RX_ADDR16_LSB_OFFSET 9 00040 #define ZB_RX_OPTIONS_OFFSET 10 00041 #define ZB_RX_DATA_OFFSET 11 00042 #define ZB_RX_OVERHEAD (8+2+1) 00043 00044 #define BROADCAST_PACKET 0x02 00045 00046 void FH_RxPacketZB::process_frame_data(const ApiFrame *const frame) 00047 { 00048 /* The caller checks that the type matches, so no need to check it here again */ 00049 00050 if (receive_cb == NULL) { 00051 return; 00052 } 00053 00054 /* We got a rx packet, decode it... */ 00055 const uint8_t *datap = frame->get_data(); 00056 const uint64_t sender64 = addr64_from_uint8_t(datap); 00057 const uint16_t sender16 = ADDR16(datap[ZB_RX_ADDR16_MSB_OFFSET], datap[ZB_RX_ADDR16_LSB_OFFSET]); 00058 const uint8_t rx_options = datap[ZB_RX_OPTIONS_OFFSET]; 00059 const RemoteXBeeZB sender = RemoteXBeeZB(sender64, sender16); 00060 00061 receive_cb(sender, rx_options & BROADCAST_PACKET, &datap[ZB_RX_DATA_OFFSET], frame->get_data_len() - ZB_RX_OVERHEAD); 00062 }
Generated on Tue Jul 12 2022 20:40:23 by
