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 LinkNode-Test by
iBeacon.h
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 #ifndef __BLE_IBEACON_H__ 00017 #define __BLE_IBEACON_H__ 00018 00019 #include "core_cmInstr.h" 00020 #include "ble/BLE.h" 00021 00022 /** 00023 * @class iBeacon 00024 * @brief iBeacon Service. This sets up a device to broadcast advertising packets to mimic an iBeacon. 00025 */ 00026 class iBeacon 00027 { 00028 public: 00029 typedef const uint8_t LocationUUID_t[16]; 00030 00031 union Payload { 00032 uint8_t raw[25]; 00033 struct { 00034 uint16_t companyID; 00035 uint8_t ID; 00036 uint8_t len; 00037 uint8_t proximityUUID[16]; 00038 uint16_t majorNumber; 00039 uint16_t minorNumber; 00040 uint8_t txPower; 00041 }; 00042 00043 Payload(LocationUUID_t uuid, uint16_t majNum, uint16_t minNum, uint8_t transmitPower, uint16_t companyIDIn) : 00044 companyID(companyIDIn), ID(0x02), len(0x15), majorNumber(__REV16(majNum)), minorNumber(__REV16(minNum)), txPower(transmitPower) 00045 { 00046 memcpy(proximityUUID, uuid, sizeof(LocationUUID_t)); 00047 } 00048 }; 00049 00050 public: 00051 iBeacon(BLE &_ble, 00052 LocationUUID_t uuid, 00053 uint16_t majNum, 00054 uint16_t minNum, 00055 uint8_t txP = 0xC8, 00056 uint16_t compID = 0x004C) : 00057 ble(_ble), data(uuid, majNum, minNum, txP, compID) 00058 { 00059 // Generate the 0x020106 part of the iBeacon Prefix. 00060 ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE ); 00061 // Generate the 0x1AFF part of the iBeacon Prefix. 00062 ble.accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, data.raw, sizeof(data.raw)); 00063 00064 // Set advertising type. 00065 ble.setAdvertisingType(GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED); 00066 } 00067 00068 protected: 00069 BLE &ble; 00070 Payload data; 00071 }; 00072 00073 typedef iBeacon iBeaconService; /* This type-alias is deprecated. Please use iBeacon directly. This alias may be dropped from a future release. */ 00074 00075 #endif //__BLE_IBEACON_H__
Generated on Tue Jul 12 2022 16:00:20 by
