ST
/
mbed-os-example-ble-EddystoneService
BLE EddystoneService example
Embed:
(wiki syntax)
Show/hide line numbers
URLFrame.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 00017 #ifndef __URLFRAME_H__ 00018 #define __URLFRAME_H__ 00019 00020 #include "EddystoneTypes.h" 00021 #include <string.h> 00022 00023 /** 00024 * Class that encapsulates data that belongs to the Eddystone-URL frame. For 00025 * more information refer to https://github.com/google/eddystone/tree/master/eddystone-url. 00026 */ 00027 class URLFrame 00028 { 00029 public: 00030 /** 00031 * Construct a new instance of this class. 00032 */ 00033 URLFrame(void); 00034 00035 /** 00036 * Construct a new instance of this class. 00037 * 00038 * @param[in] urlDataIn 00039 * A null terminated string representing a URL. 00040 */ 00041 URLFrame(const char *urlDataIn); 00042 00043 /** 00044 * Construct a new instance of this class. 00045 * 00046 * @param[in] urlDataIn 00047 * An encoded URL. 00048 * @param[in] urlDataLengthIn 00049 * The length (in bytes) of the encoded URL. 00050 */ 00051 URLFrame(UrlData_t urlDataIn, uint8_t urlDataLengthIn); 00052 00053 /** 00054 * Construct the raw bytes of the Eddystone-URL frame that will be directly 00055 * used in the advertising packets. 00056 * 00057 * @param[in] rawFrame 00058 * Pointer to the location where the raw frame will be stored. 00059 * @param[in] advPowerLevel 00060 * Power level value included withing the raw frame. 00061 */ 00062 void constructURLFrame(uint8_t* rawFrame, int8_t advPowerLevel); 00063 00064 /** 00065 * Get the size of the Eddystone-URL frame constructed with the 00066 * current state of the URLFrame object. 00067 * 00068 * @return The size in bytes of the Eddystone-URL frame. 00069 */ 00070 size_t getRawFrameSize(void) const; 00071 00072 /** 00073 * Get a pointer to the encoded URL data. 00074 * 00075 * @return A pointer to the encoded URL data. 00076 */ 00077 uint8_t* getEncodedURLData(void); 00078 00079 /** 00080 * Get the encoded URL data length. 00081 * 00082 * @return The length (in bytes) of the encoded URL data frame. 00083 */ 00084 uint8_t getEncodedURLDataLength(void) const; 00085 00086 /** 00087 * Set a new URL. 00088 * 00089 * @param[in] urlDataIn 00090 * A null terminated string containing the new URL. 00091 */ 00092 void setURLData(const char *urlDataIn); 00093 00094 /** 00095 * Set an encoded URL. 00096 * 00097 * @param[in] urlEncodedDataIn 00098 * A pointer to the encoded URL data. 00099 * @param[in] urlEncodedDataLengthIn 00100 * The lenght of the encoded URL data pointed to by @p 00101 * urlEncodedDataIn. 00102 */ 00103 void setEncodedURLData(const uint8_t* urlEncodedDataIn, const uint8_t urlEncodedDataLengthIn); 00104 00105 private: 00106 /** 00107 * Helper function that encodes a URL null terminated string into the HTTP 00108 * URL Encoding required in Eddystone-URL frames. Refer to 00109 * https://github.com/google/eddystone/blob/master/eddystone-url/README.md#eddystone-url-http-url-encoding. 00110 * 00111 * @param[in] urlDataIn 00112 * The null terminated string containing a URL to encode. 00113 */ 00114 void encodeURL(const char *urlDataIn); 00115 00116 /** 00117 * The byte ID of an Eddystone-URL frame. 00118 */ 00119 static const uint8_t FRAME_TYPE_URL = 0x10; 00120 /** 00121 * The minimum size (in bytes) of an Eddystone-URL frame. 00122 */ 00123 static const uint8_t FRAME_MIN_SIZE_URL = 2; 00124 00125 /** 00126 * The length of the encoded URL. 00127 */ 00128 uint8_t urlDataLength; 00129 /** 00130 * The enconded URL data. 00131 */ 00132 UrlData_t urlData; 00133 00134 }; 00135 00136 #endif /* __URLFRAME_H__ */
Generated on Tue Jul 12 2022 19:55:16 by 1.7.2