|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.MicroPython.BluetoothDialogs.BluetoothAdvertisement</title> |
|
4 <meta charset="UTF-8"> |
|
5 <link rel="stylesheet" href="styles.css"> |
|
6 </head> |
|
7 <body> |
|
8 <a NAME="top" ID="top"></a> |
|
9 <h1>eric7.MicroPython.BluetoothDialogs.BluetoothAdvertisement</h1> |
|
10 |
|
11 <p> |
|
12 Module implementing a class to parse and store the Bluetooth device advertisement data. |
|
13 </p> |
|
14 <h3>Global Attributes</h3> |
|
15 |
|
16 <table> |
|
17 <tr><td>ADV_DIRECT_IND</td></tr><tr><td>ADV_IND</td></tr><tr><td>ADV_NONCONN_IND</td></tr><tr><td>ADV_SCAN_IND</td></tr><tr><td>ADV_TYPE_COMPLETE_NAME</td></tr><tr><td>ADV_TYPE_MANUFACTURER</td></tr><tr><td>ADV_TYPE_SHORT_NAME</td></tr><tr><td>ADV_TYPE_SVC_DATA</td></tr><tr><td>ADV_TYPE_TX_POWER_LEVEL</td></tr><tr><td>ADV_TYPE_UUID128_COMPLETE</td></tr><tr><td>ADV_TYPE_UUID128_INCOMPLETE</td></tr><tr><td>ADV_TYPE_UUID16_COMPLETE</td></tr><tr><td>ADV_TYPE_UUID16_INCOMPLETE</td></tr><tr><td>ADV_TYPE_UUID32_COMPLETE</td></tr><tr><td>ADV_TYPE_UUID32_INCOMPLETE</td></tr><tr><td>ManufacturerId</td></tr><tr><td>SCAN_RSP</td></tr> |
|
18 </table> |
|
19 <h3>Classes</h3> |
|
20 |
|
21 <table> |
|
22 |
|
23 <tr> |
|
24 <td><a href="#BluetoothAdvertisement">BluetoothAdvertisement</a></td> |
|
25 <td>Class to parse and store the Bluetooth device advertisement data.</td> |
|
26 </tr> |
|
27 </table> |
|
28 <h3>Functions</h3> |
|
29 |
|
30 <table> |
|
31 <tr><td>None</td></tr> |
|
32 </table> |
|
33 <hr /> |
|
34 <hr /> |
|
35 <a NAME="BluetoothAdvertisement" ID="BluetoothAdvertisement"></a> |
|
36 <h2>BluetoothAdvertisement</h2> |
|
37 |
|
38 <p> |
|
39 Class to parse and store the Bluetooth device advertisement data. |
|
40 </p> |
|
41 <h3>Derived from</h3> |
|
42 None |
|
43 <h3>Class Attributes</h3> |
|
44 |
|
45 <table> |
|
46 <tr><td>None</td></tr> |
|
47 </table> |
|
48 <h3>Class Methods</h3> |
|
49 |
|
50 <table> |
|
51 <tr><td>None</td></tr> |
|
52 </table> |
|
53 <h3>Methods</h3> |
|
54 |
|
55 <table> |
|
56 |
|
57 <tr> |
|
58 <td><a href="#BluetoothAdvertisement.__init__">BluetoothAdvertisement</a></td> |
|
59 <td>Constructor</td> |
|
60 </tr> |
|
61 <tr> |
|
62 <td><a href="#BluetoothAdvertisement.__decodeField">__decodeField</a></td> |
|
63 <td>Private method to get all fields of the specified types.</td> |
|
64 </tr> |
|
65 <tr> |
|
66 <td><a href="#BluetoothAdvertisement.__splitBytes">__splitBytes</a></td> |
|
67 <td>Private method to split some data into chunks of given size.</td> |
|
68 </tr> |
|
69 <tr> |
|
70 <td><a href="#BluetoothAdvertisement.__str__">__str__</a></td> |
|
71 <td>Special method to generate a string representation.</td> |
|
72 </tr> |
|
73 <tr> |
|
74 <td><a href="#BluetoothAdvertisement.address">address</a></td> |
|
75 <td>Public method to get the address string.</td> |
|
76 </tr> |
|
77 <tr> |
|
78 <td><a href="#BluetoothAdvertisement.manufacturer">manufacturer</a></td> |
|
79 <td>Public method to get the manufacturer data.</td> |
|
80 </tr> |
|
81 <tr> |
|
82 <td><a href="#BluetoothAdvertisement.name">name</a></td> |
|
83 <td>Public method to get the complete or shortened advertised name, if available.</td> |
|
84 </tr> |
|
85 <tr> |
|
86 <td><a href="#BluetoothAdvertisement.rssi">rssi</a></td> |
|
87 <td>Public method to get the RSSI value.</td> |
|
88 </tr> |
|
89 <tr> |
|
90 <td><a href="#BluetoothAdvertisement.services">services</a></td> |
|
91 <td>Public method to get the service IDs.</td> |
|
92 </tr> |
|
93 <tr> |
|
94 <td><a href="#BluetoothAdvertisement.txPower">txPower</a></td> |
|
95 <td>Public method to get the advertised power level in dBm.</td> |
|
96 </tr> |
|
97 <tr> |
|
98 <td><a href="#BluetoothAdvertisement.update">update</a></td> |
|
99 <td>Public method to update the advertisement data.</td> |
|
100 </tr> |
|
101 </table> |
|
102 <h3>Static Methods</h3> |
|
103 |
|
104 <table> |
|
105 <tr><td>None</td></tr> |
|
106 </table> |
|
107 |
|
108 <a NAME="BluetoothAdvertisement.__init__" ID="BluetoothAdvertisement.__init__"></a> |
|
109 <h4>BluetoothAdvertisement (Constructor)</h4> |
|
110 <b>BluetoothAdvertisement</b>(<i>address</i>) |
|
111 |
|
112 <p> |
|
113 Constructor |
|
114 </p> |
|
115 <dl> |
|
116 |
|
117 <dt><i>address</i> (str)</dt> |
|
118 <dd> |
|
119 address of the device advertisement |
|
120 </dd> |
|
121 </dl> |
|
122 <a NAME="BluetoothAdvertisement.__decodeField" ID="BluetoothAdvertisement.__decodeField"></a> |
|
123 <h4>BluetoothAdvertisement.__decodeField</h4> |
|
124 <b>__decodeField</b>(<i>*advType</i>) |
|
125 |
|
126 <p> |
|
127 Private method to get all fields of the specified types. |
|
128 </p> |
|
129 <dl> |
|
130 |
|
131 <dt><i>*advType</i> (int)</dt> |
|
132 <dd> |
|
133 type of fields to be extracted |
|
134 </dd> |
|
135 </dl> |
|
136 <dl> |
|
137 <dt>Yield:</dt> |
|
138 <dd> |
|
139 requested fields |
|
140 </dd> |
|
141 </dl> |
|
142 <dl> |
|
143 <dt>Yield Type:</dt> |
|
144 <dd> |
|
145 bytes |
|
146 </dd> |
|
147 </dl> |
|
148 <a NAME="BluetoothAdvertisement.__splitBytes" ID="BluetoothAdvertisement.__splitBytes"></a> |
|
149 <h4>BluetoothAdvertisement.__splitBytes</h4> |
|
150 <b>__splitBytes</b>(<i>data, chunkSize</i>) |
|
151 |
|
152 <p> |
|
153 Private method to split some data into chunks of given size. |
|
154 </p> |
|
155 <dl> |
|
156 |
|
157 <dt><i>data</i> (bytes, bytearray, str)</dt> |
|
158 <dd> |
|
159 data to be chunked |
|
160 </dd> |
|
161 <dt><i>chunkSize</i> (int)</dt> |
|
162 <dd> |
|
163 size for each chunk |
|
164 </dd> |
|
165 </dl> |
|
166 <dl> |
|
167 <dt>Return:</dt> |
|
168 <dd> |
|
169 list of chunks |
|
170 </dd> |
|
171 </dl> |
|
172 <dl> |
|
173 <dt>Return Type:</dt> |
|
174 <dd> |
|
175 list of bytes, bytearray, str |
|
176 </dd> |
|
177 </dl> |
|
178 <a NAME="BluetoothAdvertisement.__str__" ID="BluetoothAdvertisement.__str__"></a> |
|
179 <h4>BluetoothAdvertisement.__str__</h4> |
|
180 <b>__str__</b>(<i></i>) |
|
181 |
|
182 <p> |
|
183 Special method to generate a string representation. |
|
184 </p> |
|
185 <dl> |
|
186 <dt>Return:</dt> |
|
187 <dd> |
|
188 string representation |
|
189 </dd> |
|
190 </dl> |
|
191 <dl> |
|
192 <dt>Return Type:</dt> |
|
193 <dd> |
|
194 str |
|
195 </dd> |
|
196 </dl> |
|
197 <a NAME="BluetoothAdvertisement.address" ID="BluetoothAdvertisement.address"></a> |
|
198 <h4>BluetoothAdvertisement.address</h4> |
|
199 <b>address</b>(<i></i>) |
|
200 |
|
201 <p> |
|
202 Public method to get the address string. |
|
203 </p> |
|
204 <dl> |
|
205 <dt>Return:</dt> |
|
206 <dd> |
|
207 address of the device |
|
208 </dd> |
|
209 </dl> |
|
210 <dl> |
|
211 <dt>Return Type:</dt> |
|
212 <dd> |
|
213 str |
|
214 </dd> |
|
215 </dl> |
|
216 <a NAME="BluetoothAdvertisement.manufacturer" ID="BluetoothAdvertisement.manufacturer"></a> |
|
217 <h4>BluetoothAdvertisement.manufacturer</h4> |
|
218 <b>manufacturer</b>(<i>filterId=None, withName=False</i>) |
|
219 |
|
220 <p> |
|
221 Public method to get the manufacturer data. |
|
222 </p> |
|
223 <dl> |
|
224 |
|
225 <dt><i>filterId</i> (int (optional))</dt> |
|
226 <dd> |
|
227 manufacturer ID to filter on (defaults to None) |
|
228 </dd> |
|
229 <dt><i>withName</i> (bool)</dt> |
|
230 <dd> |
|
231 flag indicating to report the manufacturer name as well |
|
232 (if available) (defaults to False) |
|
233 </dd> |
|
234 </dl> |
|
235 <dl> |
|
236 <dt>Return:</dt> |
|
237 <dd> |
|
238 tuple containing the manufacturer ID, associated data and manufacturer |
|
239 name |
|
240 </dd> |
|
241 </dl> |
|
242 <dl> |
|
243 <dt>Return Type:</dt> |
|
244 <dd> |
|
245 tuple of (int, bytes, str) |
|
246 </dd> |
|
247 </dl> |
|
248 <a NAME="BluetoothAdvertisement.name" ID="BluetoothAdvertisement.name"></a> |
|
249 <h4>BluetoothAdvertisement.name</h4> |
|
250 <b>name</b>(<i></i>) |
|
251 |
|
252 <p> |
|
253 Public method to get the complete or shortened advertised name, if available. |
|
254 </p> |
|
255 <dl> |
|
256 <dt>Return:</dt> |
|
257 <dd> |
|
258 advertised name |
|
259 </dd> |
|
260 </dl> |
|
261 <dl> |
|
262 <dt>Return Type:</dt> |
|
263 <dd> |
|
264 str |
|
265 </dd> |
|
266 </dl> |
|
267 <a NAME="BluetoothAdvertisement.rssi" ID="BluetoothAdvertisement.rssi"></a> |
|
268 <h4>BluetoothAdvertisement.rssi</h4> |
|
269 <b>rssi</b>(<i></i>) |
|
270 |
|
271 <p> |
|
272 Public method to get the RSSI value. |
|
273 </p> |
|
274 <dl> |
|
275 <dt>Return:</dt> |
|
276 <dd> |
|
277 RSSI value in dBm |
|
278 </dd> |
|
279 </dl> |
|
280 <dl> |
|
281 <dt>Return Type:</dt> |
|
282 <dd> |
|
283 int |
|
284 </dd> |
|
285 </dl> |
|
286 <a NAME="BluetoothAdvertisement.services" ID="BluetoothAdvertisement.services"></a> |
|
287 <h4>BluetoothAdvertisement.services</h4> |
|
288 <b>services</b>(<i></i>) |
|
289 |
|
290 <p> |
|
291 Public method to get the service IDs. |
|
292 </p> |
|
293 <dl> |
|
294 <dt>Return:</dt> |
|
295 <dd> |
|
296 list of tuples containing the advertised service ID and a |
|
297 flag indicating a complete ID |
|
298 </dd> |
|
299 </dl> |
|
300 <dl> |
|
301 <dt>Return Type:</dt> |
|
302 <dd> |
|
303 list of tuple of (str, bool) |
|
304 </dd> |
|
305 </dl> |
|
306 <a NAME="BluetoothAdvertisement.txPower" ID="BluetoothAdvertisement.txPower"></a> |
|
307 <h4>BluetoothAdvertisement.txPower</h4> |
|
308 <b>txPower</b>(<i></i>) |
|
309 |
|
310 <p> |
|
311 Public method to get the advertised power level in dBm. |
|
312 </p> |
|
313 <dl> |
|
314 <dt>Return:</dt> |
|
315 <dd> |
|
316 transmit power of the device (in dBm) |
|
317 </dd> |
|
318 </dl> |
|
319 <dl> |
|
320 <dt>Return Type:</dt> |
|
321 <dd> |
|
322 int |
|
323 </dd> |
|
324 </dl> |
|
325 <a NAME="BluetoothAdvertisement.update" ID="BluetoothAdvertisement.update"></a> |
|
326 <h4>BluetoothAdvertisement.update</h4> |
|
327 <b>update</b>(<i>advType, rssi, advData</i>) |
|
328 |
|
329 <p> |
|
330 Public method to update the advertisement data. |
|
331 </p> |
|
332 <dl> |
|
333 |
|
334 <dt><i>advType</i> (int)</dt> |
|
335 <dd> |
|
336 type of advertisement data |
|
337 </dd> |
|
338 <dt><i>rssi</i> (int)</dt> |
|
339 <dd> |
|
340 RSSI value in dBm |
|
341 </dd> |
|
342 <dt><i>advData</i> (bytes)</dt> |
|
343 <dd> |
|
344 advertisement data |
|
345 </dd> |
|
346 </dl> |
|
347 <div align="right"><a href="#top">Up</a></div> |
|
348 <hr /> |
|
349 </body></html> |