BLE EddystoneService example
This example is a fork of the following mbed-os example:
https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-EddystoneService/
Please read the documentation in this page.
source/UIDFrame.h@0:4c8f8bf32a99, 2016-07-26 (annotated)
- Committer:
- Vincent Coubard
- Date:
- Tue Jul 26 14:40:25 2016 +0100
- Revision:
- 0:4c8f8bf32a99
- Child:
- 1:9db4d46bb63f
Update example at tag mbed-os-5.0.1-rc1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Vincent Coubard |
0:4c8f8bf32a99 | 1 | /* mbed Microcontroller Library |
Vincent Coubard |
0:4c8f8bf32a99 | 2 | * Copyright (c) 2006-2015 ARM Limited |
Vincent Coubard |
0:4c8f8bf32a99 | 3 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Vincent Coubard |
0:4c8f8bf32a99 | 5 | * you may not use this file except in compliance with the License. |
Vincent Coubard |
0:4c8f8bf32a99 | 6 | * You may obtain a copy of the License at |
Vincent Coubard |
0:4c8f8bf32a99 | 7 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Vincent Coubard |
0:4c8f8bf32a99 | 9 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 10 | * Unless required by applicable law or agreed to in writing, software |
Vincent Coubard |
0:4c8f8bf32a99 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
Vincent Coubard |
0:4c8f8bf32a99 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Vincent Coubard |
0:4c8f8bf32a99 | 13 | * See the License for the specific language governing permissions and |
Vincent Coubard |
0:4c8f8bf32a99 | 14 | * limitations under the License. |
Vincent Coubard |
0:4c8f8bf32a99 | 15 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 16 | |
Vincent Coubard |
0:4c8f8bf32a99 | 17 | #ifndef __UIDFRAME_H__ |
Vincent Coubard |
0:4c8f8bf32a99 | 18 | #define __UIDFRAME_H__ |
Vincent Coubard |
0:4c8f8bf32a99 | 19 | |
Vincent Coubard |
0:4c8f8bf32a99 | 20 | #include <string.h> |
Vincent Coubard |
0:4c8f8bf32a99 | 21 | #include "EddystoneTypes.h" |
Vincent Coubard |
0:4c8f8bf32a99 | 22 | |
Vincent Coubard |
0:4c8f8bf32a99 | 23 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 24 | * Class that encapsulates data that belongs to the Eddystone-UID frame. For |
Vincent Coubard |
0:4c8f8bf32a99 | 25 | * more information refer to https://github.com/google/eddystone/tree/master/eddystone-uid. |
Vincent Coubard |
0:4c8f8bf32a99 | 26 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 27 | class UIDFrame |
Vincent Coubard |
0:4c8f8bf32a99 | 28 | { |
Vincent Coubard |
0:4c8f8bf32a99 | 29 | public: |
Vincent Coubard |
0:4c8f8bf32a99 | 30 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 31 | * Construct a new instance of this class. |
Vincent Coubard |
0:4c8f8bf32a99 | 32 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 33 | UIDFrame(void); |
Vincent Coubard |
0:4c8f8bf32a99 | 34 | |
Vincent Coubard |
0:4c8f8bf32a99 | 35 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 36 | * Construct a new instance of this class. |
Vincent Coubard |
0:4c8f8bf32a99 | 37 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 38 | * @param[in] uidNamespaceIDIn |
Vincent Coubard |
0:4c8f8bf32a99 | 39 | * The Eddystone-UID namespace ID. |
Vincent Coubard |
0:4c8f8bf32a99 | 40 | * @param[in] uidInstanceIDIn |
Vincent Coubard |
0:4c8f8bf32a99 | 41 | * The Eddystone-UID instance ID. |
Vincent Coubard |
0:4c8f8bf32a99 | 42 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 43 | UIDFrame(const UIDNamespaceID_t uidNamespaceIDIn, const UIDInstanceID_t uidInstanceIDIn); |
Vincent Coubard |
0:4c8f8bf32a99 | 44 | |
Vincent Coubard |
0:4c8f8bf32a99 | 45 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 46 | * Set the instance and namespace ID. |
Vincent Coubard |
0:4c8f8bf32a99 | 47 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 48 | * @param[in] uidNamespaceIDIn |
Vincent Coubard |
0:4c8f8bf32a99 | 49 | * The new Eddystone-UID namespace ID. |
Vincent Coubard |
0:4c8f8bf32a99 | 50 | * @param[in] uidInstanceIDIn |
Vincent Coubard |
0:4c8f8bf32a99 | 51 | * The new Eddystone-UID instance ID. |
Vincent Coubard |
0:4c8f8bf32a99 | 52 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 53 | void setUIDData(const UIDNamespaceID_t &uidNamespaceIDIn, const UIDInstanceID_t &uidInstanceIDIn); |
Vincent Coubard |
0:4c8f8bf32a99 | 54 | |
Vincent Coubard |
0:4c8f8bf32a99 | 55 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 56 | * Construct the raw bytes of the Eddystone-UID frame that will be directly |
Vincent Coubard |
0:4c8f8bf32a99 | 57 | * used in the advertising packets. |
Vincent Coubard |
0:4c8f8bf32a99 | 58 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 59 | * @param[in] rawFrame |
Vincent Coubard |
0:4c8f8bf32a99 | 60 | * Pointer to the location where the raw frame will be stored. |
Vincent Coubard |
0:4c8f8bf32a99 | 61 | * @param[in] advPowerLevel |
Vincent Coubard |
0:4c8f8bf32a99 | 62 | * Power level value included withing the raw frame. |
Vincent Coubard |
0:4c8f8bf32a99 | 63 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 64 | void constructUIDFrame(uint8_t *rawFrame, int8_t advPowerLevel); |
Vincent Coubard |
0:4c8f8bf32a99 | 65 | |
Vincent Coubard |
0:4c8f8bf32a99 | 66 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 67 | * Get the size of the Eddystone-UID frame constructed with the |
Vincent Coubard |
0:4c8f8bf32a99 | 68 | * current state of the UIDFrame object. |
Vincent Coubard |
0:4c8f8bf32a99 | 69 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 70 | * @return The size in bytes of the Eddystone-UID frame. |
Vincent Coubard |
0:4c8f8bf32a99 | 71 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 72 | size_t getRawFrameSize(void) const; |
Vincent Coubard |
0:4c8f8bf32a99 | 73 | |
Vincent Coubard |
0:4c8f8bf32a99 | 74 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 75 | * Get the Eddystone-UID namespace ID. |
Vincent Coubard |
0:4c8f8bf32a99 | 76 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 77 | * @return A pointer to the namespace ID. |
Vincent Coubard |
0:4c8f8bf32a99 | 78 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 79 | uint8_t* getUIDNamespaceID(void); |
Vincent Coubard |
0:4c8f8bf32a99 | 80 | |
Vincent Coubard |
0:4c8f8bf32a99 | 81 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 82 | * Get the Eddystone-UID instance ID. |
Vincent Coubard |
0:4c8f8bf32a99 | 83 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 84 | * @return A pointer to the instance ID. |
Vincent Coubard |
0:4c8f8bf32a99 | 85 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 86 | uint8_t* getUIDInstanceID(void); |
Vincent Coubard |
0:4c8f8bf32a99 | 87 | |
Vincent Coubard |
0:4c8f8bf32a99 | 88 | private: |
Vincent Coubard |
0:4c8f8bf32a99 | 89 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 90 | * The byte ID of an Eddystone-UID frame. |
Vincent Coubard |
0:4c8f8bf32a99 | 91 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 92 | static const uint8_t FRAME_TYPE_UID = 0x00; |
Vincent Coubard |
0:4c8f8bf32a99 | 93 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 94 | * The size (in bytes) of an Eddystone-UID frame. |
Vincent Coubard |
0:4c8f8bf32a99 | 95 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 96 | static const uint8_t FRAME_SIZE_UID = 20; |
Vincent Coubard |
0:4c8f8bf32a99 | 97 | |
Vincent Coubard |
0:4c8f8bf32a99 | 98 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 99 | * The Eddystone-UID namespace ID. |
Vincent Coubard |
0:4c8f8bf32a99 | 100 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 101 | UIDNamespaceID_t uidNamespaceID; |
Vincent Coubard |
0:4c8f8bf32a99 | 102 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 103 | * The Eddystone-UID instance ID. |
Vincent Coubard |
0:4c8f8bf32a99 | 104 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 105 | UIDInstanceID_t uidInstanceID; |
Vincent Coubard |
0:4c8f8bf32a99 | 106 | }; |
Vincent Coubard |
0:4c8f8bf32a99 | 107 | |
Vincent Coubard |
0:4c8f8bf32a99 | 108 | #endif /* __UIDFRAME_H__ */ |