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/URLFrame.h@41:97bbb1eb43d7, 2017-07-28 (annotated)
- Committer:
- bcostm
- Date:
- Fri Jul 28 10:07:05 2017 +0200
- Revision:
- 41:97bbb1eb43d7
- Parent:
- 3:5120491ba317
Add DISCO_L475VG_IOT01A in mbed_app.json
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 3:5120491ba317 | 1 | /* mbed Microcontroller Library |
mbed_official | 3:5120491ba317 | 2 | * Copyright (c) 2006-2015 ARM Limited |
mbed_official | 3:5120491ba317 | 3 | * |
mbed_official | 3:5120491ba317 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
mbed_official | 3:5120491ba317 | 5 | * you may not use this file except in compliance with the License. |
mbed_official | 3:5120491ba317 | 6 | * You may obtain a copy of the License at |
mbed_official | 3:5120491ba317 | 7 | * |
mbed_official | 3:5120491ba317 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
mbed_official | 3:5120491ba317 | 9 | * |
mbed_official | 3:5120491ba317 | 10 | * Unless required by applicable law or agreed to in writing, software |
mbed_official | 3:5120491ba317 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
mbed_official | 3:5120491ba317 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mbed_official | 3:5120491ba317 | 13 | * See the License for the specific language governing permissions and |
mbed_official | 3:5120491ba317 | 14 | * limitations under the License. |
mbed_official | 3:5120491ba317 | 15 | */ |
mbed_official | 3:5120491ba317 | 16 | |
mbed_official | 3:5120491ba317 | 17 | #ifndef __URLFRAME_H__ |
mbed_official | 3:5120491ba317 | 18 | #define __URLFRAME_H__ |
mbed_official | 3:5120491ba317 | 19 | |
mbed_official | 3:5120491ba317 | 20 | #include "EddystoneTypes.h" |
mbed_official | 3:5120491ba317 | 21 | #include <string.h> |
mbed_official | 3:5120491ba317 | 22 | |
mbed_official | 3:5120491ba317 | 23 | /** |
mbed_official | 3:5120491ba317 | 24 | * Class that encapsulates data that belongs to the Eddystone-URL frame. For |
mbed_official | 3:5120491ba317 | 25 | * more information refer to https://github.com/google/eddystone/tree/master/eddystone-url. |
mbed_official | 3:5120491ba317 | 26 | */ |
mbed_official | 3:5120491ba317 | 27 | class URLFrame |
mbed_official | 3:5120491ba317 | 28 | { |
mbed_official | 3:5120491ba317 | 29 | public: |
mbed_official | 3:5120491ba317 | 30 | /** |
mbed_official | 3:5120491ba317 | 31 | * Construct a new instance of this class. |
mbed_official | 3:5120491ba317 | 32 | */ |
mbed_official | 3:5120491ba317 | 33 | URLFrame(void); |
mbed_official | 3:5120491ba317 | 34 | |
mbed_official | 3:5120491ba317 | 35 | /** |
mbed_official | 3:5120491ba317 | 36 | * Construct a new instance of this class. |
mbed_official | 3:5120491ba317 | 37 | * |
mbed_official | 3:5120491ba317 | 38 | * @param[in] urlDataIn |
mbed_official | 3:5120491ba317 | 39 | * A null terminated string representing a URL. |
mbed_official | 3:5120491ba317 | 40 | */ |
mbed_official | 3:5120491ba317 | 41 | URLFrame(const char *urlDataIn); |
mbed_official | 3:5120491ba317 | 42 | |
mbed_official | 3:5120491ba317 | 43 | /** |
mbed_official | 3:5120491ba317 | 44 | * Construct a new instance of this class. |
mbed_official | 3:5120491ba317 | 45 | * |
mbed_official | 3:5120491ba317 | 46 | * @param[in] urlDataIn |
mbed_official | 3:5120491ba317 | 47 | * An encoded URL. |
mbed_official | 3:5120491ba317 | 48 | * @param[in] urlDataLengthIn |
mbed_official | 3:5120491ba317 | 49 | * The length (in bytes) of the encoded URL. |
mbed_official | 3:5120491ba317 | 50 | */ |
mbed_official | 3:5120491ba317 | 51 | URLFrame(UrlData_t urlDataIn, uint8_t urlDataLengthIn); |
mbed_official | 3:5120491ba317 | 52 | |
mbed_official | 3:5120491ba317 | 53 | /** |
mbed_official | 3:5120491ba317 | 54 | * Construct the raw bytes of the Eddystone-URL frame that will be directly |
mbed_official | 3:5120491ba317 | 55 | * used in the advertising packets. |
mbed_official | 3:5120491ba317 | 56 | * |
mbed_official | 3:5120491ba317 | 57 | * @param[in] rawFrame |
mbed_official | 3:5120491ba317 | 58 | * Pointer to the location where the raw frame will be stored. |
mbed_official | 3:5120491ba317 | 59 | * @param[in] advPowerLevel |
mbed_official | 3:5120491ba317 | 60 | * Power level value included withing the raw frame. |
mbed_official | 3:5120491ba317 | 61 | */ |
mbed_official | 3:5120491ba317 | 62 | void constructURLFrame(uint8_t* rawFrame, int8_t advPowerLevel); |
mbed_official | 3:5120491ba317 | 63 | |
mbed_official | 3:5120491ba317 | 64 | /** |
mbed_official | 3:5120491ba317 | 65 | * Get the size of the Eddystone-URL frame constructed with the |
mbed_official | 3:5120491ba317 | 66 | * current state of the URLFrame object. |
mbed_official | 3:5120491ba317 | 67 | * |
mbed_official | 3:5120491ba317 | 68 | * @return The size in bytes of the Eddystone-URL frame. |
mbed_official | 3:5120491ba317 | 69 | */ |
mbed_official | 3:5120491ba317 | 70 | size_t getRawFrameSize(void) const; |
mbed_official | 3:5120491ba317 | 71 | |
mbed_official | 3:5120491ba317 | 72 | /** |
mbed_official | 3:5120491ba317 | 73 | * Get a pointer to the encoded URL data. |
mbed_official | 3:5120491ba317 | 74 | * |
mbed_official | 3:5120491ba317 | 75 | * @return A pointer to the encoded URL data. |
mbed_official | 3:5120491ba317 | 76 | */ |
mbed_official | 3:5120491ba317 | 77 | uint8_t* getEncodedURLData(void); |
mbed_official | 3:5120491ba317 | 78 | |
mbed_official | 3:5120491ba317 | 79 | /** |
mbed_official | 3:5120491ba317 | 80 | * Get the encoded URL data length. |
mbed_official | 3:5120491ba317 | 81 | * |
mbed_official | 3:5120491ba317 | 82 | * @return The length (in bytes) of the encoded URL data frame. |
mbed_official | 3:5120491ba317 | 83 | */ |
mbed_official | 3:5120491ba317 | 84 | uint8_t getEncodedURLDataLength(void) const; |
mbed_official | 3:5120491ba317 | 85 | |
mbed_official | 3:5120491ba317 | 86 | /** |
mbed_official | 3:5120491ba317 | 87 | * Set a new URL. |
mbed_official | 3:5120491ba317 | 88 | * |
mbed_official | 3:5120491ba317 | 89 | * @param[in] urlDataIn |
mbed_official | 3:5120491ba317 | 90 | * A null terminated string containing the new URL. |
mbed_official | 3:5120491ba317 | 91 | */ |
mbed_official | 3:5120491ba317 | 92 | void setURLData(const char *urlDataIn); |
mbed_official | 3:5120491ba317 | 93 | |
mbed_official | 3:5120491ba317 | 94 | /** |
mbed_official | 3:5120491ba317 | 95 | * Set an encoded URL. |
mbed_official | 3:5120491ba317 | 96 | * |
mbed_official | 3:5120491ba317 | 97 | * @param[in] urlEncodedDataIn |
mbed_official | 3:5120491ba317 | 98 | * A pointer to the encoded URL data. |
mbed_official | 3:5120491ba317 | 99 | * @param[in] urlEncodedDataLengthIn |
mbed_official | 3:5120491ba317 | 100 | * The lenght of the encoded URL data pointed to by @p |
mbed_official | 3:5120491ba317 | 101 | * urlEncodedDataIn. |
mbed_official | 3:5120491ba317 | 102 | */ |
mbed_official | 3:5120491ba317 | 103 | void setEncodedURLData(const uint8_t* urlEncodedDataIn, const uint8_t urlEncodedDataLengthIn); |
mbed_official | 3:5120491ba317 | 104 | |
mbed_official | 3:5120491ba317 | 105 | private: |
mbed_official | 3:5120491ba317 | 106 | /** |
mbed_official | 3:5120491ba317 | 107 | * Helper function that encodes a URL null terminated string into the HTTP |
mbed_official | 3:5120491ba317 | 108 | * URL Encoding required in Eddystone-URL frames. Refer to |
mbed_official | 3:5120491ba317 | 109 | * https://github.com/google/eddystone/blob/master/eddystone-url/README.md#eddystone-url-http-url-encoding. |
mbed_official | 3:5120491ba317 | 110 | * |
mbed_official | 3:5120491ba317 | 111 | * @param[in] urlDataIn |
mbed_official | 3:5120491ba317 | 112 | * The null terminated string containing a URL to encode. |
mbed_official | 3:5120491ba317 | 113 | */ |
mbed_official | 3:5120491ba317 | 114 | void encodeURL(const char *urlDataIn); |
mbed_official | 3:5120491ba317 | 115 | |
mbed_official | 3:5120491ba317 | 116 | /** |
mbed_official | 3:5120491ba317 | 117 | * The byte ID of an Eddystone-URL frame. |
mbed_official | 3:5120491ba317 | 118 | */ |
mbed_official | 3:5120491ba317 | 119 | static const uint8_t FRAME_TYPE_URL = 0x10; |
mbed_official | 3:5120491ba317 | 120 | /** |
mbed_official | 3:5120491ba317 | 121 | * The minimum size (in bytes) of an Eddystone-URL frame. |
mbed_official | 3:5120491ba317 | 122 | */ |
mbed_official | 3:5120491ba317 | 123 | static const uint8_t FRAME_MIN_SIZE_URL = 2; |
mbed_official | 3:5120491ba317 | 124 | |
mbed_official | 3:5120491ba317 | 125 | /** |
mbed_official | 3:5120491ba317 | 126 | * The length of the encoded URL. |
mbed_official | 3:5120491ba317 | 127 | */ |
mbed_official | 3:5120491ba317 | 128 | uint8_t urlDataLength; |
mbed_official | 3:5120491ba317 | 129 | /** |
mbed_official | 3:5120491ba317 | 130 | * The enconded URL data. |
mbed_official | 3:5120491ba317 | 131 | */ |
mbed_official | 3:5120491ba317 | 132 | UrlData_t urlData; |
mbed_official | 3:5120491ba317 | 133 | |
mbed_official | 3:5120491ba317 | 134 | }; |
mbed_official | 3:5120491ba317 | 135 | |
mbed_official | 3:5120491ba317 | 136 | #endif /* __URLFRAME_H__ */ |