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
DigiMeshFrames.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 "DigiMeshFrames.h" 00014 00015 #define FRAME_ID_LEN 1 00016 #define ADDR64_LEN 8 00017 #define ADDR16_LEN 2 00018 #define BROADCAST_RADIOUS_LEN 1 00019 #define OPTIONS_LEN 1 00020 #define TX_REQUEST_OVERHEAD (FRAME_ID_LEN + ADDR64_LEN + \ 00021 ADDR16_LEN + BROADCAST_RADIOUS_LEN + \ 00022 OPTIONS_LEN) 00023 #define SOURCE_EP_LEN 1 00024 #define DEST_EP_LEN 1 00025 #define CLUSTER_ID_LEN 2 00026 #define PROFILE_ID_LEN 2 00027 00028 #define EXP_ADDR_OVERHEAD (TX_REQUEST_OVERHEAD + SOURCE_EP_LEN + \ 00029 DEST_EP_LEN + CLUSTER_ID_LEN + \ 00030 PROFILE_ID_LEN) 00031 00032 /** Class constructor */ 00033 TxFrameDM::TxFrameDM(uint64_t addr, uint16_t addr16, uint8_t broadcast_rad, uint8_t tx_opt, 00034 const uint8_t *const data, uint16_t len) 00035 { 00036 uint8_t frame_data[TX_REQUEST_OVERHEAD + len]; 00037 00038 _frame_id = get_next_frame_id(); 00039 00040 /* copy the frame id, the 64bit remote address, the 16bit network address, 00041 * the broad cast radious, the options byte and the frame data */ 00042 00043 frame_data[0] = _frame_id; 00044 rmemcpy(&frame_data[1], (const uint8_t *)&addr, sizeof addr); 00045 frame_data[9] = (uint8_t)(addr16 >> 8); 00046 frame_data[10] = (uint8_t)addr16; 00047 frame_data[11] = broadcast_rad; 00048 frame_data[12] = tx_opt; 00049 00050 if (len) { 00051 memcpy(&frame_data[13], data, len); 00052 } 00053 00054 set_api_frame(TxReqZBDM, frame_data, TX_REQUEST_OVERHEAD + len); 00055 } 00056 00057 /** Class constructor */ 00058 TxFrameDM::TxFrameDM(uint64_t addr, uint16_t addr16, uint8_t source_ep, uint8_t dest_ep, 00059 uint16_t cluster_id, uint16_t profile_id, uint8_t broadcast_rad, 00060 uint8_t tx_opt, const uint8_t *const data, uint16_t len) 00061 { 00062 uint8_t frame_data[EXP_ADDR_OVERHEAD + len]; 00063 00064 _frame_id = get_next_frame_id(); 00065 00066 /* copy the frame id, the 64bit remote address, the 16bit network address, 00067 * the end point source and destination addresses, the cluster and profile IDs, 00068 * the broad cast radious, the options byte and the frame data */ 00069 00070 frame_data[0] = _frame_id; 00071 rmemcpy(&frame_data[1], (const uint8_t *)&addr, sizeof addr); 00072 frame_data[9] = (uint8_t)(addr16 >> 8); 00073 frame_data[10] = (uint8_t)addr16; 00074 frame_data[11] = source_ep; 00075 frame_data[12] = dest_ep; 00076 frame_data[13] = (uint8_t)(cluster_id >> 8); 00077 frame_data[14] = (uint8_t)cluster_id; 00078 frame_data[15] = (uint8_t)(profile_id >> 8); 00079 frame_data[16] = (uint8_t)profile_id; 00080 frame_data[17] = broadcast_rad; 00081 frame_data[18] = tx_opt; 00082 00083 if (len) { 00084 memcpy(&frame_data[19], data, len); 00085 } 00086 00087 set_api_frame(ExpAddrCmd, frame_data, EXP_ADDR_OVERHEAD + len); 00088 }
Generated on Tue Jul 12 2022 20:40:23 by
