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_RxPacketDM.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_RxPacketDM.h" 00014 00015 using namespace XBeeLib; 00016 00017 /** Class constructor */ 00018 FH_RxPacketDM::FH_RxPacketDM() : FrameHandler(ApiFrame::RxPacketAO0), receive_cb(NULL) 00019 { 00020 } 00021 00022 /** Class destructor */ 00023 FH_RxPacketDM::~FH_RxPacketDM() 00024 { 00025 } 00026 00027 void FH_RxPacketDM::register_receive_cb(receive_dm_cb_t function) 00028 { 00029 receive_cb = function; 00030 } 00031 00032 void FH_RxPacketDM::unregister_receive_cb(void) 00033 { 00034 receive_cb = NULL; 00035 } 00036 00037 /* DM RX packet offsets */ 00038 #define DM_RX_OPTIONS_OFFSET 10 00039 #define DM_RX_DATA_OFFSET 11 00040 #define DM_RX_OVERHEAD (8+2+1) 00041 00042 #define BROADCAST_PACKET 0x02 00043 00044 void FH_RxPacketDM::process_frame_data(const ApiFrame *const frame) 00045 { 00046 /* The caller checks that the type matches, so no need to check it here again */ 00047 00048 if (receive_cb == NULL) { 00049 return; 00050 } 00051 00052 /* We got a rx packet, decode it... */ 00053 const uint8_t *datap = frame->get_data(); 00054 const uint64_t sender64 = addr64_from_uint8_t(datap); 00055 const uint8_t rx_options = datap[DM_RX_OPTIONS_OFFSET]; 00056 const RemoteXBeeDM sender = RemoteXBeeDM(sender64); 00057 00058 receive_cb(sender, rx_options & BROADCAST_PACKET, &datap[DM_RX_DATA_OFFSET], frame->get_data_len() - DM_RX_OVERHEAD); 00059 }
Generated on Tue Jul 12 2022 20:40:23 by
