test
Embed:
(wiki syntax)
Show/hide line numbers
802_Frames.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 "802_Frames.h" 00014 00015 #define FRAME_ID_LEN 1 00016 #define ADDR64_LEN 8 00017 #define ADDR16_LEN 2 00018 #define OPTIONS_LEN 1 00019 #define TX_REQUEST_OVERHEAD (FRAME_ID_LEN + ADDR64_LEN + OPTIONS_LEN) 00020 #define TX_REQUEST_OVERHEAD2 (FRAME_ID_LEN + ADDR16_LEN + OPTIONS_LEN) 00021 00022 /** Class constructor */ 00023 TxFrame802::TxFrame802(uint64_t addr, uint8_t tx_options, 00024 const uint8_t *const data, uint16_t len) 00025 { 00026 uint8_t frame_data[TX_REQUEST_OVERHEAD + len]; 00027 00028 _frame_id = get_next_frame_id(); 00029 00030 /* copy the frame id, the 64bit remote address, the tx options byte 00031 * and the frame data */ 00032 00033 frame_data[0] = _frame_id; 00034 rmemcpy(&frame_data[1], (const uint8_t *)&addr, sizeof addr); 00035 frame_data[9] = tx_options; 00036 00037 if (len) { 00038 memcpy(&frame_data[10], data, len); 00039 } 00040 00041 set_api_frame(TxReq64Bit, frame_data, TX_REQUEST_OVERHEAD + len); 00042 } 00043 00044 /** Class constructor */ 00045 TxFrame802::TxFrame802(uint16_t addr16, uint8_t tx_options, 00046 const uint8_t *const data, uint16_t len) 00047 { 00048 uint8_t frame_data[TX_REQUEST_OVERHEAD2 + len]; 00049 00050 _frame_id = get_next_frame_id(); 00051 00052 /* copy the frame id, the 16bit remote address, the tx options byte 00053 * and the frame data */ 00054 00055 frame_data[0] = _frame_id; 00056 frame_data[1] = (uint8_t)(addr16 >> 8); 00057 frame_data[2] = (uint8_t)addr16; 00058 frame_data[3] = tx_options; 00059 00060 if (len) { 00061 memcpy(&frame_data[4], data, len); 00062 } 00063 00064 set_api_frame(TxReq16Bit, frame_data, TX_REQUEST_OVERHEAD2 + len); 00065 }
Generated on Tue Nov 1 2022 06:41:57 by 1.7.2