ST
/
mbed-os-example-ble-EddystoneService
BLE EddystoneService example
Embed:
(wiki syntax)
Show/hide line numbers
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 memset(uidNamespaceID, 0, sizeof(UIDNamespaceID_t)); 00022 memset(uidInstanceID, 0, sizeof(UIDInstanceID_t)); 00023 } 00024 00025 UIDFrame::UIDFrame(const UIDNamespaceID_t uidNamespaceIDIn, const UIDInstanceID_t uidInstanceIDIn) 00026 { 00027 memcpy(uidNamespaceID, uidNamespaceIDIn, sizeof(UIDNamespaceID_t)); 00028 memcpy(uidInstanceID, uidInstanceIDIn, sizeof(UIDInstanceID_t)); 00029 } 00030 00031 void UIDFrame::setUIDData(const UIDNamespaceID_t &uidNamespaceIDIn, const UIDInstanceID_t &uidInstanceIDIn) 00032 { 00033 memcpy(uidNamespaceID, uidNamespaceIDIn, sizeof(UIDNamespaceID_t)); 00034 memcpy(uidInstanceID, uidInstanceIDIn, sizeof(UIDInstanceID_t)); 00035 } 00036 00037 void UIDFrame::constructUIDFrame(uint8_t *rawFrame, int8_t advPowerLevel) 00038 { 00039 size_t index = 0; 00040 00041 rawFrame[index++] = EDDYSTONE_UUID[0]; // 16-bit Eddystone UUID 00042 rawFrame[index++] = EDDYSTONE_UUID[1]; 00043 rawFrame[index++] = FRAME_TYPE_UID; // 1B Type 00044 rawFrame[index++] = advPowerLevel; // 1B Power @ 0meter 00045 00046 memcpy(rawFrame + index, uidNamespaceID, sizeof(UIDNamespaceID_t)); // 10B Namespace ID 00047 index += sizeof(UIDNamespaceID_t); 00048 memcpy(rawFrame + index, uidInstanceID, sizeof(UIDInstanceID_t)); // 6B Instance ID 00049 index += sizeof(UIDInstanceID_t); 00050 00051 memset(rawFrame + index, 0, 2 * sizeof(uint8_t)); // 2B RFU, which are unused 00052 } 00053 00054 size_t UIDFrame::getRawFrameSize(void) const 00055 { 00056 return FRAME_SIZE_UID + EDDYSTONE_UUID_SIZE; 00057 } 00058 00059 uint8_t* UIDFrame::getUIDNamespaceID(void) 00060 { 00061 return uidNamespaceID; 00062 } 00063 00064 uint8_t* UIDFrame::getUIDInstanceID(void) 00065 { 00066 return uidInstanceID; 00067 }
Generated on Tue Jul 12 2022 19:55:16 by 1.7.2