Merge ~sylvain-pineau/checkbox-support:fix-1837350 into checkbox-support:master
- Git
- lp:~sylvain-pineau/checkbox-support
- fix-1837350
- Merge into master
Status: | Merged |
---|---|
Approved by: | Sylvain Pineau |
Approved revision: | e4b7ad7f3a3110d94b52c12eb3ed1ee6b902a892 |
Merged at revision: | 66ec4c055327bbb9ada36e33111dc59724173fb9 |
Proposed branch: | ~sylvain-pineau/checkbox-support:fix-1837350 |
Merge into: | checkbox-support:master |
Diff against target: |
368 lines (+171/-91) 2 files modified
checkbox_support/vendor/aioblescan/aioblescan.py (+168/-87) checkbox_support/vendor/aioblescan/eddystone.py (+3/-4) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Devices Certification Bot | Needs Fixing | ||
Sylvain Pineau (community) | Approve | ||
Review via email: mp+376054@code.launchpad.net |
Commit message
Description of the change
Update aioblescan to include You-Sheng Yang fixes (See https:/
Devices Certification Bot (ce-certification-qa) wrote : | # |
The merge was fine but running tests failed.
[xenial] [09:05:42] starting container
Device project added to xenial-testing
[bionic] [09:05:45] starting container
Device project added to bionic-testing
[xenial] [09:05:50] provisioning container
[bionic] [09:05:56] provisioning container
[xenial] [09:06:12] Starting tests...
[xenial] Found a test script: ./requirements/
[bionic] [09:06:12] Starting tests...
[bionic] Found a test script: ./requirements/
[xenial] [09:06:13] container-
[xenial] output: https:/
[xenial] [09:06:15] Fixing file permissions in source directory
[xenial] [09:06:15] Destroying container
[bionic] [09:06:41] container-
[bionic] [09:06:41] Fixing file permissions in source directory
[bionic] [09:06:41] Destroying container
Preview Diff
1 | diff --git a/checkbox_support/vendor/aioblescan/aioblescan.py b/checkbox_support/vendor/aioblescan/aioblescan.py |
2 | index b0d9d0d..745686f 100644 |
3 | --- a/checkbox_support/vendor/aioblescan/aioblescan.py |
4 | +++ b/checkbox_support/vendor/aioblescan/aioblescan.py |
5 | @@ -25,7 +25,7 @@ |
6 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR |
7 | # IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE |
8 | |
9 | -import socket, asyncio, sys |
10 | +import socket, asyncio |
11 | from struct import pack, unpack, calcsize |
12 | |
13 | |
14 | @@ -106,15 +106,14 @@ class Bool: |
15 | |
16 | """ |
17 | def __init__(self,name,val=True): |
18 | - self.name=name |
19 | - self.val=val |
20 | + self.name = name |
21 | + self.val = val |
22 | |
23 | def encode (self): |
24 | - val=(self.val and b'\x01') or b'\x00' |
25 | - return val |
26 | + return b'\x01' if self.val else b'\x00' |
27 | |
28 | def decode(self,data): |
29 | - self.val= data[:1]==b"\x01" |
30 | + self.val = (data[:1] == b"\x01") |
31 | return data[1:] |
32 | |
33 | def __len__(self): |
34 | @@ -769,7 +768,7 @@ class HCI_Cmd_LE_Scan_Enable(HCI_Command): |
35 | |
36 | """ |
37 | |
38 | - def __init__(self,enable=True,filter_dups=True): |
39 | + def __init__(self,enable=True,filter_dups=False): |
40 | super(self.__class__, self).__init__(b"\x08",b"\x0c") |
41 | self.payload.append(Bool("enable",enable)) |
42 | self.payload.append(Bool("filter",filter_dups)) |
43 | @@ -803,7 +802,7 @@ class HCI_Cmd_LE_Set_Scan_Params(HCI_Command): |
44 | |
45 | """ |
46 | |
47 | - def __init__(self,scan_type=0x0,interval=10, window=750, oaddr_type=0,filter=0): |
48 | + def __init__(self,scan_type=0x1,interval=10, window=750, oaddr_type=0,filter=0): |
49 | |
50 | super(self.__class__, self).__init__(b"\x08",b"\x0b") |
51 | self.payload.append(EnumByte("scan type",scan_type, |
52 | @@ -1000,7 +999,11 @@ class HCI_LE_Meta_Event(Packet): |
53 | data=x.decode(data) |
54 | code=self.payload[0] |
55 | if code.val==b"\x02": |
56 | - ev=HCI_LEM_Adv_Report() |
57 | + ev=RepeatedField("Reports", HCI_LEM_Adv_Report) |
58 | + data=ev.decode(data) |
59 | + self.payload.append(ev) |
60 | + elif code.val==b"\x0d": |
61 | + ev=RepeatedField("Ext Adv Report", HCI_LEM_Ext_Adv_Report) |
62 | data=ev.decode(data) |
63 | self.payload.append(ev) |
64 | else: |
65 | @@ -1014,12 +1017,50 @@ class HCI_LE_Meta_Event(Packet): |
66 | for x in self.payload: |
67 | x.show(depth+1) |
68 | |
69 | +class ManufacturerSpecificData(Packet): |
70 | + def __init__(self, name="Manufacturer Specific Data"): |
71 | + self.name = name |
72 | + self.payload = [UShortInt("Manufacturer ID", endian="little"), Itself("Payload")] |
73 | + |
74 | + def decode(self, data): |
75 | + # Warning: Will consume all the data you give it! |
76 | + for p in self.payload: |
77 | + data = p.decode(data) |
78 | + return data |
79 | + |
80 | + def show(self, depth=0): |
81 | + print("{}{}:".format(PRINT_INDENT*depth,self.name)) |
82 | + for x in self.payload: |
83 | + x.show(depth+1) |
84 | + |
85 | + |
86 | +class RepeatedField(Packet): |
87 | + def __init__(self, name, subfield_cls, length_field_cls=UIntByte): |
88 | + self.name = name |
89 | + self.subfield_cls = subfield_cls |
90 | + self.length_field = length_field_cls("count of " + name) |
91 | + self.payload = [] |
92 | + |
93 | + def decode(self, data): |
94 | + self.payload = [] |
95 | + data = self.length_field.decode(data) |
96 | + for x in range(self.length_field.val): |
97 | + field = self.subfield_cls() |
98 | + data = field.decode(data) |
99 | + self.payload.append(field) |
100 | + |
101 | + return data |
102 | + |
103 | + def show(self, depth=0): |
104 | + print("{}{}: {}".format(PRINT_INDENT*depth, self.name, self.length_field.val)) |
105 | + for field in self.payload: |
106 | + field.show(depth+1) |
107 | + |
108 | |
109 | class HCI_LEM_Adv_Report(Packet): |
110 | def __init__(self): |
111 | self.name="Adv Report" |
112 | - self.payload=[UIntByte("num reports"), |
113 | - EnumByte("ev type",0,{0:"generic adv", 3:"no connection adv", 4:"scan rsp"}), |
114 | + self.payload=[EnumByte("ev type",0,{0:"generic adv", 3:"no connection adv", 4:"scan rsp"}), |
115 | EnumByte("addr type",0,{0:"public", 1:"random"}), |
116 | MACAddr("peer"),UIntByte("length")] |
117 | |
118 | @@ -1029,80 +1070,15 @@ class HCI_LEM_Adv_Report(Packet): |
119 | for x in self.payload: |
120 | data=x.decode(data) |
121 | #Now we have a sequence of len, type data with possibly a RSSI byte at the end |
122 | - while len(data) > 1: |
123 | - length=UIntByte("sublen") |
124 | - data=length.decode(data) |
125 | - code=EIR_Hdr() |
126 | - data=code.decode(data) |
127 | - |
128 | - if code.val == 0x01: |
129 | - #Flag |
130 | - myinfo=BitFieldByte("flags",0,["Undef","Undef","Simul LE - BR/EDR (Host)","Simul LE - BR/EDR (Control.)","BR/EDR Not Supported", |
131 | - "LE General Disc.","LE Limited Disc."]) |
132 | - xx=myinfo.decode(data[:length.val-len(code)]) |
133 | - self.payload.append(myinfo) |
134 | - elif code.val == 0x02: |
135 | - myinfo=NBytes_List("Incomplete uuids",2) |
136 | - xx=myinfo.decode(data[:length.val-len(code)]) |
137 | - self.payload.append(myinfo) |
138 | - elif code.val == 0x03: |
139 | - myinfo=NBytes_List("Complete uuids",2) |
140 | - xx=myinfo.decode(data[:length.val-len(code)]) |
141 | - self.payload.append(myinfo) |
142 | - elif code.val == 0x04: |
143 | - myinfo=NBytes_List("Incomplete uuids",4) |
144 | - xx=myinfo.decode(data[:length.val-len(code)]) |
145 | - self.payload.append(myinfo) |
146 | - elif code.val == 0x05: |
147 | - myinfo=NBytes_List("Complete uuids",4) |
148 | - xx=myinfo.decode(data[:length.val-len(code)]) |
149 | - self.payload.append(myinfo) |
150 | - elif code.val == 0x06: |
151 | - myinfo=NBytes_List("Incomplete uuids",16) |
152 | - xx=myinfo.decode(data[:length.val-len(code)]) |
153 | - self.payload.append(myinfo) |
154 | - elif code.val == 0x07: |
155 | - myinfo=NBytes_List("Complete uuids",16) |
156 | - xx=myinfo.decode(data[:length.val-len(code)]) |
157 | - self.payload.append(myinfo) |
158 | - elif code.val == 0x14: |
159 | - myinfo=NBytes_List("Service Solicitation uuid",2) |
160 | - xx=myinfo.decode(data[:length.val-len(code)]) |
161 | - self.payload.append(myinfo) |
162 | - elif code.val == 0x16: |
163 | - myinfo=Adv_Data("Advertised Data",2) |
164 | - xx=myinfo.decode(data[:length.val-len(code)]) |
165 | - self.payload.append(myinfo) |
166 | - elif code.val == 0x1f: |
167 | - myinfo=NBytes_List("Service Solicitation uuid",4) |
168 | - xx=myinfo.decode(data[:length.val-len(code)]) |
169 | - self.payload.append(myinfo) |
170 | - elif code.val == 0x20: |
171 | - myinfo=Adv_Data("Advertised Data",4) |
172 | - xx=myinfo.decode(data[:length.val-len(code)]) |
173 | - self.payload.append(myinfo) |
174 | - elif code.val == 0x15: |
175 | - myinfo=NBytes_List("Service Solicitation uuid",16) |
176 | - xx=myinfo.decode(data[:length.val-len(code)]) |
177 | - self.payload.append(myinfo) |
178 | - elif code.val == 0x21: |
179 | - myinfo=Adv_Data("Advertised Data",16) |
180 | - xx=myinfo.decode(data[:length.val-len(code)]) |
181 | - self.payload.append(myinfo) |
182 | - elif code.val == 0x08: |
183 | - myinfo=String("Short Name") |
184 | - xx=myinfo.decode(data[:length.val-len(code)]) |
185 | - self.payload.append(myinfo) |
186 | - elif code.val == 0x09: |
187 | - myinfo=String("Complete Name") |
188 | - xx=myinfo.decode(data[:length.val-len(code)]) |
189 | - self.payload.append(myinfo) |
190 | - else: |
191 | - myinfo=Itself("Payload for %s"%code.strval) |
192 | - xx=myinfo.decode(data[:length.val-len(code)]) |
193 | - self.payload.append(myinfo) |
194 | - |
195 | - data=data[length.val-len(code):] |
196 | + datalength = self.payload[-1].val |
197 | + |
198 | + while datalength > 0: |
199 | + ad=AD_Structure() |
200 | + data=ad.decode(data) |
201 | + self.payload.append(ad) |
202 | + |
203 | + datalength -= len(ad) |
204 | + |
205 | if data: |
206 | myinfo=IntByte("rssi") |
207 | data=myinfo.decode(data) |
208 | @@ -1114,6 +1090,43 @@ class HCI_LEM_Adv_Report(Packet): |
209 | for x in self.payload: |
210 | x.show(depth+1) |
211 | |
212 | + |
213 | +class HCI_LEM_Ext_Adv_Report(Packet): |
214 | + def __init__(self): |
215 | + self.name="Ext Adv Report" |
216 | + self.payload=[BitFieldByte("ev type",0,["Connectable", "Scannable", "Directed", "Scan Response", "Legacy", "Incomplete/more", "Incomplete/truncated", "RFU"]), |
217 | + UIntByte("unused"), |
218 | + EnumByte("addr type",0,{0:"public device", 1:"random device", 2:"public identity", 3:"random identity", 0xFF:"anonymous"}), |
219 | + MACAddr("peer"), |
220 | + EnumByte("primary phy",1,{1:"LE 1M", 3:"LE Coded"}), |
221 | + EnumByte("secondary phy",0,{0:"N/A", 1:"LE 1M", 2:"LE 2M", 3:"LE Coded"}), |
222 | + EnumByte("adv sid",255,{0:"0x00", 1:"0x01", 2:"0x02", 3:"0x03", 4:"0x04", 5:"0x05", 6:"0x06", 7:"0x07", 8:"0x08", 9:"0x09", 10:"0x0A", 11:"0x0B", 12:"0x0C", 13:"0x0D", 14:"0x0E", 15:"0x0F", 0xFF:"N/A"}), |
223 | + IntByte("tx power"), |
224 | + IntByte("rssi"), |
225 | + UShortInt("adv interval", endian="little"), |
226 | + EnumByte("direct addr type",0,{0:"public device", 1:"random device", 2:"public identity", 3:"random identity", 0xFE:"random device"}), |
227 | + MACAddr("direct addr"), |
228 | + UIntByte("data len")] |
229 | + |
230 | + |
231 | + def decode(self,data): |
232 | + |
233 | + for x in self.payload: |
234 | + data=x.decode(data) |
235 | + |
236 | + datalength = self.payload[-1].val |
237 | + while datalength > 0: |
238 | + ad=AD_Structure() |
239 | + data=ad.decode(data) |
240 | + self.payload.append(ad) |
241 | + |
242 | + datalength -= len(ad) |
243 | + |
244 | + def show(self,depth=0): |
245 | + print("{}{}:".format(PRINT_INDENT*depth,self.name)) |
246 | + for x in self.payload: |
247 | + x.show(depth+1) |
248 | + |
249 | class EIR_Hdr(Packet): |
250 | def __init__(self): |
251 | self.type= EnumByte("type", 0, { |
252 | @@ -1154,8 +1167,8 @@ class EIR_Hdr(Packet): |
253 | def decode(self,data): |
254 | return self.type.decode(data) |
255 | |
256 | - def show(self): |
257 | - return self.type.show() |
258 | + def show(self,depth=0): |
259 | + return self.type.show(depth) |
260 | |
261 | @property |
262 | def val(self): |
263 | @@ -1195,7 +1208,75 @@ class Adv_Data(Packet): |
264 | resu+=len(x) |
265 | return resu |
266 | |
267 | +class AD_Structure(Packet): |
268 | + def __init__(self): |
269 | + self.name="" |
270 | + self.length=0 |
271 | + self.payload=[] |
272 | + |
273 | + def __len__(self): |
274 | + return self.length |
275 | + |
276 | + def decode(self,data): |
277 | + length=UIntByte("sublen") |
278 | + data=length.decode(data) |
279 | + self.length=len(length)+length.val |
280 | + self.payload=[] |
281 | + if length.val == 0: |
282 | + return data |
283 | + |
284 | + type=EIR_Hdr() |
285 | + data=type.decode(data) |
286 | + |
287 | + val = None |
288 | + if type.val == 0x01: |
289 | + val=BitFieldByte("flags",0,["Undef","Undef","Simul LE - BR/EDR (Host)","Simul LE - BR/EDR (Control.)","BR/EDR Not Supported", |
290 | + "LE General Disc.","LE Limited Disc."]) |
291 | + elif type.val == 0x02: |
292 | + val=NBytes_List("Incomplete uuids",2) |
293 | + elif type.val == 0x03: |
294 | + val=NBytes_List("Complete uuids",2) |
295 | + elif type.val == 0x04: |
296 | + val=NBytes_List("Incomplete uuids",4) |
297 | + elif type.val == 0x05: |
298 | + val=NBytes_List("Complete uuids",4) |
299 | + elif type.val == 0x06: |
300 | + val=NBytes_List("Incomplete uuids",16) |
301 | + elif type.val == 0x07: |
302 | + val=NBytes_List("Complete uuids",16) |
303 | + elif type.val == 0x08: |
304 | + val=String("Short Name") |
305 | + elif type.val == 0x09: |
306 | + val=String("Complete Name") |
307 | + elif type.val == 0x14: |
308 | + val=NBytes_List("Service Solicitation uuid",2) |
309 | + elif type.val == 0x15: |
310 | + val=NBytes_List("Service Solicitation uuid",16) |
311 | + elif type.val == 0x16: |
312 | + val=Adv_Data("Advertised Data",2) |
313 | + elif type.val == 0x1f: |
314 | + val=NBytes_List("Service Solicitation uuid",4) |
315 | + elif type.val == 0x20: |
316 | + val=Adv_Data("Advertised Data",4) |
317 | + elif type.val == 0x21: |
318 | + val=Adv_Data("Advertised Data",16) |
319 | + elif type.val == 0xff: |
320 | + val=ManufacturerSpecificData() |
321 | + else: |
322 | + val=Itself("Payload for %s"%type.strval) |
323 | + |
324 | + # Some data type may consume all input data, therefore an copy |
325 | + # is passed instead. |
326 | + val.decode(data[:length.val-len(type)]) |
327 | + |
328 | + self.payload.append(type) |
329 | + self.payload.append(val) |
330 | + |
331 | + return data[length.val-len(type):] |
332 | |
333 | + def show(self,depth=0): |
334 | + for x in self.payload: |
335 | + x.show(depth+1) |
336 | |
337 | # |
338 | # The defs are over. Now the realstuffs |
339 | diff --git a/checkbox_support/vendor/aioblescan/eddystone.py b/checkbox_support/vendor/aioblescan/eddystone.py |
340 | index 3cc0d2c..1ee0217 100644 |
341 | --- a/checkbox_support/vendor/aioblescan/eddystone.py |
342 | +++ b/checkbox_support/vendor/aioblescan/eddystone.py |
343 | @@ -114,22 +114,21 @@ class EddyStone(object): |
344 | url_schemes.index((myurl.scheme,myhostname.startswith("www."))))) |
345 | if myhostname.startswith("www."): |
346 | myhostname = myhostname[4:] |
347 | - |
348 | extval=None |
349 | if myhostname.split(".")[-1] in url_domain: |
350 | extval = url_domain.index(myhostname.split(".")[-1]) |
351 | myhostname = ".".join(myhostname.split(".")[:-1]) |
352 | - if extval and not mypath.startswith("/"): |
353 | + if extval is not None and not mypath.startswith("/"): |
354 | extval+=7 |
355 | else: |
356 | if myurl.port is None: |
357 | - if extval: |
358 | + if extval is not None: |
359 | mypath = mypath[1:] |
360 | else: |
361 | extval += 7 |
362 | encodedurl.append(aios.String("URL string")) |
363 | encodedurl[-1].val = myhostname |
364 | - if extval: |
365 | + if extval is not None: |
366 | encodedurl.append(aios.IntByte("URL Extention",extval)) |
367 | |
368 | if myurl.port: |
self-approved