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.
UIDFrame.cpp
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2015 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #include "UIDFrame.h" 00018 00019 UIDFrame::UIDFrame(void) { 00020 } 00021 00022 void UIDFrame::clearFrame(uint8_t* frame) { 00023 frame[FRAME_LEN_OFFSET] = 0; // Set frame length to zero to clear it 00024 } 00025 00026 void UIDFrame::setData(uint8_t *rawFrame, int8_t advTxPower, const uint8_t* uidData) { 00027 size_t index = 0; 00028 rawFrame[index++] = UID_HEADER_LEN + UID_LENGTH; // UID length + overhead of four bytes below 00029 rawFrame[index++] = EDDYSTONE_UUID[0]; // LSB 16-bit Eddystone UUID (little endian) 00030 rawFrame[index++] = EDDYSTONE_UUID[1]; // MSB 00031 rawFrame[index++] = FRAME_TYPE_UID; // 1B Type 00032 rawFrame[index++] = advTxPower; // 1B Power @ 0meter 00033 00034 memcpy(rawFrame + index, uidData, UID_LENGTH); // UID = 10B NamespaceID + 6B InstanceID 00035 } 00036 00037 uint8_t* UIDFrame::getData(uint8_t* rawFrame) { 00038 return &(rawFrame[UID_DATA_OFFSET]); 00039 } 00040 00041 uint8_t UIDFrame::getDataLength(uint8_t* rawFrame) 00042 { 00043 return rawFrame[FRAME_LEN_OFFSET] - EDDYSTONE_UUID_LEN; 00044 } 00045 00046 uint8_t* UIDFrame::getAdvFrame(uint8_t* rawFrame) 00047 { 00048 return &(rawFrame[ADV_FRAME_OFFSET]); 00049 } 00050 00051 uint8_t UIDFrame::getAdvFrameLength(uint8_t* rawFrame) 00052 { 00053 return rawFrame[FRAME_LEN_OFFSET]; 00054 } 00055 00056 uint8_t* UIDFrame::getUid(uint8_t* rawFrame) 00057 { 00058 return &(rawFrame[UID_VALUE_OFFSET]); 00059 } 00060 00061 uint8_t UIDFrame::getUidLength(uint8_t* rawFrame) 00062 { 00063 return rawFrame[FRAME_LEN_OFFSET] - UID_HEADER_LEN; 00064 } 00065 00066 void UIDFrame::setAdvTxPower(uint8_t* rawFrame, int8_t advTxPower) 00067 { 00068 rawFrame[UID_TXPOWER_OFFSET] = advTxPower; 00069 }
Generated on Thu Jul 14 2022 09:28:18 by
1.7.2