test_p2p_wifi_display.py 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. # Wi-Fi Display test cases
  2. # Copyright (c) 2013, Jouni Malinen <j@w1.fi>
  3. #
  4. # This software may be distributed under the terms of the BSD license.
  5. # See README for more details.
  6. from remotehost import remote_compatible
  7. import logging
  8. logger = logging.getLogger()
  9. import time
  10. import threading
  11. import Queue
  12. import hwsim_utils
  13. import utils
  14. from p2p_utils import *
  15. def test_wifi_display(dev):
  16. """Wi-Fi Display extensions to P2P"""
  17. wfd_devinfo = "00411c440028"
  18. dev[0].request("SET wifi_display 1")
  19. dev[0].request("WFD_SUBELEM_SET 0 0006" + wfd_devinfo)
  20. if wfd_devinfo not in dev[0].request("WFD_SUBELEM_GET 0"):
  21. raise Exception("Could not fetch back configured subelement")
  22. # Associated BSSID
  23. dev[0].request("WFD_SUBELEM_SET 1 0006020304050607")
  24. # Coupled Sink
  25. dev[0].request("WFD_SUBELEM_SET 6 000700000000000000")
  26. # Session Info
  27. dev[0].request("WFD_SUBELEM_SET 9 0000")
  28. # WFD Extended Capability
  29. dev[0].request("WFD_SUBELEM_SET 7 00020000")
  30. # WFD Content Protection
  31. prot = "0001" + "00"
  32. dev[0].request("WFD_SUBELEM_SET 5 " + prot)
  33. # WFD Video Formats
  34. video = "0015" + "010203040506070809101112131415161718192021"
  35. dev[0].request("WFD_SUBELEM_SET 3 " + video)
  36. # WFD 3D Video Formats
  37. video_3d = "0011" + "0102030405060708091011121314151617"
  38. dev[0].request("WFD_SUBELEM_SET 4 " + video_3d)
  39. # WFD Audio Formats
  40. audio = "000f" + "010203040506070809101112131415"
  41. dev[0].request("WFD_SUBELEM_SET 2 " + audio)
  42. elems = dev[0].request("WFD_SUBELEM_GET all")
  43. if wfd_devinfo not in elems:
  44. raise Exception("Could not fetch back configured subelements")
  45. wfd_devinfo2 = "00001c440028"
  46. dev[1].request("SET wifi_display 1")
  47. dev[1].request("WFD_SUBELEM_SET 0 0006" + wfd_devinfo2)
  48. if wfd_devinfo2 not in dev[1].request("WFD_SUBELEM_GET 0"):
  49. raise Exception("Could not fetch back configured subelement")
  50. dev[0].p2p_listen()
  51. if "FAIL" in dev[1].global_request("P2P_SERV_DISC_REQ " + dev[0].p2p_dev_addr() + " wifi-display [source][pri-sink] 2,3,4,5"):
  52. raise Exception("Setting SD request failed")
  53. dev[1].p2p_find(social=True)
  54. ev = dev[0].wait_global_event(["P2P-SERV-DISC-REQ"], timeout=10)
  55. if ev is None:
  56. raise Exception("Device discovery request not reported")
  57. ev = dev[1].wait_global_event(["P2P-DEVICE-FOUND"], timeout=5)
  58. if ev is None:
  59. raise Exception("Device discovery timed out")
  60. if "wfd_dev_info=0x" + wfd_devinfo not in ev:
  61. raise Exception("Wi-Fi Display Info not in P2P-DEVICE-FOUND event")
  62. if "new=1" not in ev:
  63. raise Exception("new=1 flag missing from P2P-DEVICE-FOUND event")
  64. ev = dev[1].wait_global_event(["P2P-SERV-DISC-RESP"], timeout=5)
  65. if ev is None:
  66. raise Exception("Service discovery timed out")
  67. if prot not in ev:
  68. raise Exception("WFD Content Protection missing from WSD response")
  69. if video not in ev:
  70. raise Exception("WFD Video Formats missing from WSD response")
  71. if video_3d not in ev:
  72. raise Exception("WFD 3D Video Formats missing from WSD response")
  73. if audio not in ev:
  74. raise Exception("WFD Audio Formats missing from WSD response")
  75. dev[1].dump_monitor()
  76. dev[0].request("WFD_SUBELEM_SET 0 0006" + wfd_devinfo2)
  77. ev = dev[1].wait_global_event(["P2P-DEVICE-FOUND"], timeout=15)
  78. if ev is None:
  79. raise Exception("Peer info update timed out")
  80. if "new=0" not in ev:
  81. raise Exception("new=0 flag missing from P2P-DEVICE-FOUND event")
  82. if "wfd_dev_info=0x" + wfd_devinfo2 not in ev:
  83. raise Exception("Wi-Fi Display Info not in P2P-DEVICE-FOUND event")
  84. dev[1].dump_monitor()
  85. dev[0].request("WFD_SUBELEM_SET 0 0006" + wfd_devinfo)
  86. ev = dev[1].wait_global_event(["P2P-DEVICE-FOUND"], timeout=15)
  87. if ev is None:
  88. raise Exception("Peer info update timed out")
  89. if "new=0" not in ev:
  90. raise Exception("new=0 flag missing from P2P-DEVICE-FOUND event")
  91. if "wfd_dev_info=0x" + wfd_devinfo not in ev:
  92. raise Exception("Wi-Fi Display Info not in P2P-DEVICE-FOUND event")
  93. pin = dev[0].wps_read_pin()
  94. dev[0].p2p_go_neg_auth(dev[1].p2p_dev_addr(), pin, 'display')
  95. res1 = dev[1].p2p_go_neg_init(dev[0].p2p_dev_addr(), pin, 'enter',
  96. timeout=20, go_intent=15, freq=2437)
  97. res2 = dev[0].p2p_go_neg_auth_result()
  98. bss = dev[0].get_bss("p2p_dev_addr=" + dev[1].p2p_dev_addr())
  99. if bss['bssid'] != dev[1].p2p_interface_addr():
  100. raise Exception("Unexpected BSSID in the BSS entry for the GO")
  101. if wfd_devinfo2 not in bss['wfd_subelems']:
  102. raise Exception("Could not see wfd_subelems in GO's BSS entry")
  103. peer = dev[0].get_peer(dev[1].p2p_dev_addr())
  104. if wfd_devinfo2 not in peer['wfd_subelems']:
  105. raise Exception("Could not see wfd_subelems in GO's peer entry")
  106. peer = dev[1].get_peer(dev[0].p2p_dev_addr())
  107. if wfd_devinfo not in peer['wfd_subelems']:
  108. raise Exception("Could not see wfd_subelems in client's peer entry")
  109. wfd_devinfo3 = "00001c440028"
  110. dev[2].request("SET wifi_display 1")
  111. dev[2].request("WFD_SUBELEM_SET 0 0006" + wfd_devinfo3)
  112. dev[2].p2p_find(social=True)
  113. ev = dev[2].wait_global_event(["P2P-DEVICE-FOUND"], timeout=5)
  114. if ev is None:
  115. raise Exception("Device discovery timed out")
  116. if dev[1].p2p_dev_addr() not in ev:
  117. ev = dev[2].wait_global_event(["P2P-DEVICE-FOUND"], timeout=5)
  118. if ev is None:
  119. raise Exception("Device discovery timed out")
  120. if dev[1].p2p_dev_addr() not in ev:
  121. raise Exception("Could not discover GO")
  122. if "wfd_dev_info=0x" + wfd_devinfo2 not in ev:
  123. raise Exception("Wi-Fi Display Info not in P2P-DEVICE-FOUND event")
  124. bss = dev[2].get_bss("p2p_dev_addr=" + dev[1].p2p_dev_addr())
  125. if bss['bssid'] != dev[1].p2p_interface_addr():
  126. raise Exception("Unexpected BSSID in the BSS entry for the GO")
  127. if wfd_devinfo2 not in bss['wfd_subelems']:
  128. raise Exception("Could not see wfd_subelems in GO's BSS entry")
  129. peer = dev[2].get_peer(dev[1].p2p_dev_addr())
  130. if wfd_devinfo2 not in peer['wfd_subelems']:
  131. raise Exception("Could not see wfd_subelems in GO's peer entry")
  132. dev[2].p2p_stop_find()
  133. if dev[0].request("WFD_SUBELEM_GET 2") != audio:
  134. raise Exception("Unexpected WFD_SUBELEM_GET 2 value")
  135. if dev[0].request("WFD_SUBELEM_GET 3") != video:
  136. raise Exception("Unexpected WFD_SUBELEM_GET 3 value")
  137. if dev[0].request("WFD_SUBELEM_GET 4") != video_3d:
  138. raise Exception("Unexpected WFD_SUBELEM_GET 42 value")
  139. if dev[0].request("WFD_SUBELEM_GET 5") != prot:
  140. raise Exception("Unexpected WFD_SUBELEM_GET 5 value")
  141. if "FAIL" not in dev[0].request("WFD_SUBELEM_SET "):
  142. raise Exception("Unexpected WFD_SUBELEM_SET success")
  143. if "FAIL" not in dev[0].request("WFD_SUBELEM_SET 6"):
  144. raise Exception("Unexpected WFD_SUBELEM_SET success")
  145. if "OK" not in dev[0].request("WFD_SUBELEM_SET 6 "):
  146. raise Exception("Unexpected WFD_SUBELEM_SET failure")
  147. if "FAIL" not in dev[0].request("WFD_SUBELEM_SET 6 0"):
  148. raise Exception("Unexpected WFD_SUBELEM_SET success")
  149. if "FAIL" not in dev[0].request("WFD_SUBELEM_SET 6 0q"):
  150. raise Exception("Unexpected WFD_SUBELEM_SET success")
  151. if dev[0].request("WFD_SUBELEM_GET 6") != "":
  152. raise Exception("Unexpected WFD_SUBELEM_GET 6 response")
  153. if dev[0].request("WFD_SUBELEM_GET 8") != "":
  154. raise Exception("Unexpected WFD_SUBELEM_GET 8 response")
  155. if dev[0].global_request("WFD_SUBELEM_GET 2") != audio:
  156. raise Exception("Unexpected WFD_SUBELEM_GET 2 value from global interface")
  157. if "OK" not in dev[0].global_request("WFD_SUBELEM_SET 1 0006020304050608"):
  158. raise Exception("WFD_SUBELEM_SET failed on global interface")
  159. if dev[0].request("WFD_SUBELEM_GET 1") != "0006020304050608":
  160. raise Exception("Unexpected WFD_SUBELEM_GET 1 value (per-interface)")
  161. elems = dev[0].request("WFD_SUBELEM_GET all")
  162. if "OK" not in dev[0].request("WFD_SUBELEM_SET all " + elems):
  163. raise Exception("WFD_SUBELEM_SET all failed")
  164. if dev[0].request("WFD_SUBELEM_GET all") != elems:
  165. raise Exception("Mismatch in WFS_SUBELEM_SET/GET all")
  166. test = "00000600411c440028"
  167. if "OK" not in dev[0].request("WFD_SUBELEM_SET all " + test):
  168. raise Exception("WFD_SUBELEM_SET all failed")
  169. if dev[0].request("WFD_SUBELEM_GET all") != test:
  170. raise Exception("Mismatch in WFS_SUBELEM_SET/GET all")
  171. if "FAIL" not in dev[0].request("WFD_SUBELEM_SET all qwerty"):
  172. raise Exception("Invalid WFD_SUBELEM_SET all succeeded")
  173. if "FAIL" not in dev[0].request("WFD_SUBELEM_SET all 11"):
  174. raise Exception("Invalid WFD_SUBELEM_SET all succeeded")
  175. dev[0].request("WFD_SUBELEM_SET all 112233445566")
  176. dev[0].request("WFD_SUBELEM_SET all ff0000fe0000fd00")
  177. if "FAIL" not in dev[0].request("WFD_SUBELEM_SET 300 112233"):
  178. raise Exception("Invalid WFD_SUBELEM_SET 300 succeeded")
  179. if "FAIL" not in dev[0].request("WFD_SUBELEM_SET -1 112233"):
  180. raise Exception("Invalid WFD_SUBELEM_SET -1 succeeded")
  181. if "FAIL" not in dev[0].request("WFD_SUBELEM_GET 300"):
  182. raise Exception("Invalid WFD_SUBELEM_GET 300 succeeded")
  183. if "FAIL" not in dev[0].request("WFD_SUBELEM_GET -1"):
  184. raise Exception("Invalid WFD_SUBELEM_GET -1 succeeded")
  185. dev[0].request("SET wifi_display 0")
  186. dev[1].request("SET wifi_display 0")
  187. dev[2].request("SET wifi_display 0")
  188. def test_wifi_display_r2(dev):
  189. """Wi-Fi Display extensions to P2P with R2 subelems"""
  190. wfd_devinfo = "00411c440028"
  191. dev[0].request("SET wifi_display 1")
  192. dev[0].request("WFD_SUBELEM_SET 0 0006" + wfd_devinfo)
  193. # Associated BSSID
  194. dev[0].request("WFD_SUBELEM_SET 1 0006020304050607")
  195. # Coupled Sink
  196. dev[0].request("WFD_SUBELEM_SET 6 000700000000000000")
  197. # Session Info
  198. dev[0].request("WFD_SUBELEM_SET 9 0000")
  199. # WFD Extended Capability
  200. dev[0].request("WFD_SUBELEM_SET 7 00020000")
  201. # WFD Content Protection
  202. prot = "0001" + "00"
  203. dev[0].request("WFD_SUBELEM_SET 5 " + prot)
  204. # WFD Video Formats
  205. video = "0015" + "010203040506070809101112131415161718192021"
  206. dev[0].request("WFD_SUBELEM_SET 3 " + video)
  207. # WFD 3D Video Formats
  208. video_3d = "0011" + "0102030405060708091011121314151617"
  209. dev[0].request("WFD_SUBELEM_SET 4 " + video_3d)
  210. # WFD Audio Formats
  211. audio = "000f" + "010203040506070809101112131415"
  212. dev[0].request("WFD_SUBELEM_SET 2 " + audio)
  213. # MAC Info
  214. mac_info = "0006" + "112233445566"
  215. dev[0].request("WFD_SUBELEM_SET 10 " + mac_info)
  216. # R2 Device Info
  217. r2_dev_info = "0006" + "aabbccddeeff"
  218. dev[0].request("WFD_SUBELEM_SET 11 " + r2_dev_info)
  219. elems = dev[0].request("WFD_SUBELEM_GET all")
  220. if wfd_devinfo not in elems:
  221. raise Exception("Could not fetch back configured subelements")
  222. wfd_devinfo2 = "00001c440028"
  223. dev[1].request("SET wifi_display 1")
  224. dev[1].request("WFD_SUBELEM_SET 0 0006" + wfd_devinfo2)
  225. if wfd_devinfo2 not in dev[1].request("WFD_SUBELEM_GET 0"):
  226. raise Exception("Could not fetch back configured subelement")
  227. dev[0].p2p_listen()
  228. dev[1].p2p_find(social=True)
  229. ev = dev[1].wait_global_event(["P2P-DEVICE-FOUND"], timeout=5)
  230. if ev is None:
  231. raise Exception("Device discovery timed out")
  232. if "wfd_dev_info=0x" + wfd_devinfo not in ev:
  233. raise Exception("Wi-Fi Display Info not in P2P-DEVICE-FOUND event")
  234. if "new=1" not in ev:
  235. raise Exception("new=1 flag missing from P2P-DEVICE-FOUND event")
  236. pin = dev[0].wps_read_pin()
  237. dev[0].p2p_go_neg_auth(dev[1].p2p_dev_addr(), pin, 'display')
  238. res1 = dev[1].p2p_go_neg_init(dev[0].p2p_dev_addr(), pin, 'enter',
  239. timeout=20, go_intent=15, freq=2437)
  240. res2 = dev[0].p2p_go_neg_auth_result()
  241. bss = dev[0].get_bss("p2p_dev_addr=" + dev[1].p2p_dev_addr())
  242. if bss['bssid'] != dev[1].p2p_interface_addr():
  243. raise Exception("Unexpected BSSID in the BSS entry for the GO")
  244. if wfd_devinfo2 not in bss['wfd_subelems']:
  245. raise Exception("Could not see wfd_subelems in GO's BSS entry")
  246. peer = dev[0].get_peer(dev[1].p2p_dev_addr())
  247. if wfd_devinfo2 not in peer['wfd_subelems']:
  248. raise Exception("Could not see wfd_subelems in GO's peer entry")
  249. peer = dev[1].get_peer(dev[0].p2p_dev_addr())
  250. if wfd_devinfo not in peer['wfd_subelems']:
  251. raise Exception("Could not see wfd_subelems in client's peer entry")
  252. if r2_dev_info not in peer['wfd_subelems']:
  253. raise Exception("Could not see r2_dev_info in client's peer entry")
  254. elems = dev[0].request("WFD_SUBELEM_GET all")
  255. if "OK" not in dev[0].request("WFD_SUBELEM_SET all " + elems):
  256. raise Exception("WFD_SUBELEM_SET all failed")
  257. if dev[0].request("WFD_SUBELEM_GET all") != elems:
  258. raise Exception("Mismatch in WFS_SUBELEM_SET/GET all")
  259. test = "00000600411c440028"
  260. if "OK" not in dev[0].request("WFD_SUBELEM_SET all " + test):
  261. raise Exception("WFD_SUBELEM_SET all failed")
  262. if dev[0].request("WFD_SUBELEM_GET all") != test:
  263. raise Exception("Mismatch in WFS_SUBELEM_SET/GET all")
  264. dev[0].request("SET wifi_display 0")
  265. dev[1].request("SET wifi_display 0")
  266. dev[2].request("SET wifi_display 0")
  267. def enable_wifi_display(dev):
  268. dev.request("SET wifi_display 1")
  269. dev.request("WFD_SUBELEM_SET 0 000600411c440028")
  270. def test_wifi_display_go_invite(dev):
  271. """P2P GO with Wi-Fi Display inviting a client to join"""
  272. addr0 = dev[0].p2p_dev_addr()
  273. addr1 = dev[1].p2p_dev_addr()
  274. try:
  275. enable_wifi_display(dev[0])
  276. enable_wifi_display(dev[1])
  277. enable_wifi_display(dev[2])
  278. dev[1].p2p_listen()
  279. if not dev[0].discover_peer(addr1, social=True):
  280. raise Exception("Peer " + addr1 + " not found")
  281. dev[0].p2p_listen()
  282. if not dev[1].discover_peer(addr0, social=True):
  283. raise Exception("Peer " + addr0 + " not found")
  284. dev[1].p2p_listen()
  285. logger.info("Authorize invitation")
  286. pin = dev[1].wps_read_pin()
  287. dev[1].global_request("P2P_CONNECT " + addr0 + " " + pin + " join auth")
  288. dev[0].p2p_start_go(freq=2412)
  289. # Add test client to the group
  290. connect_cli(dev[0], dev[2], social=True, freq=2412)
  291. logger.info("Invite peer to join the group")
  292. dev[0].p2p_go_authorize_client(pin)
  293. dev[0].global_request("P2P_INVITE group=" + dev[0].group_ifname + " peer=" + addr1)
  294. ev = dev[1].wait_global_event(["P2P-INVITATION-RECEIVED",
  295. "P2P-GROUP-STARTED"], timeout=20)
  296. if ev is None:
  297. raise Exception("Timeout on invitation on peer")
  298. if "P2P-INVITATION-RECEIVED" in ev:
  299. raise Exception("Unexpected request to accept pre-authorized invitation")
  300. dev[0].remove_group()
  301. dev[1].wait_go_ending_session()
  302. dev[2].wait_go_ending_session()
  303. finally:
  304. dev[0].request("SET wifi_display 0")
  305. dev[1].request("SET wifi_display 0")
  306. dev[2].request("SET wifi_display 0")
  307. def test_wifi_display_persistent_group(dev):
  308. """P2P persistent group formation and re-invocation with Wi-Fi Display enabled"""
  309. try:
  310. enable_wifi_display(dev[0])
  311. enable_wifi_display(dev[1])
  312. enable_wifi_display(dev[2])
  313. form(dev[0], dev[1])
  314. peer = dev[1].get_peer(dev[0].p2p_dev_addr())
  315. listen_freq = peer['listen_freq']
  316. invite_from_cli(dev[0], dev[1])
  317. invite_from_go(dev[0], dev[1])
  318. dev[0].dump_monitor()
  319. dev[1].dump_monitor()
  320. networks = dev[0].list_networks(p2p=True)
  321. if len(networks) != 1:
  322. raise Exception("Unexpected number of networks")
  323. if "[P2P-PERSISTENT]" not in networks[0]['flags']:
  324. raise Exception("Not the persistent group data")
  325. if "OK" not in dev[0].global_request("P2P_GROUP_ADD persistent=" + networks[0]['id'] + " freq=" + listen_freq):
  326. raise Exception("Could not start GO")
  327. ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=2)
  328. if ev is None:
  329. raise Exception("GO start up timed out")
  330. dev[0].group_form_result(ev)
  331. connect_cli(dev[0], dev[2], social=True, freq=listen_freq)
  332. dev[0].dump_monitor()
  333. dev[1].dump_monitor()
  334. invite(dev[1], dev[0])
  335. ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=30)
  336. if ev is None:
  337. raise Exception("Timeout on group re-invocation (on client)")
  338. dev[1].group_form_result(ev)
  339. ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=0.1)
  340. if ev is not None:
  341. raise Exception("Unexpected P2P-GROUP-START on GO")
  342. hwsim_utils.test_connectivity_p2p(dev[0], dev[1])
  343. finally:
  344. dev[0].request("SET wifi_display 0")
  345. dev[1].request("SET wifi_display 0")
  346. dev[2].request("SET wifi_display 0")
  347. @remote_compatible
  348. def test_wifi_display_invalid_subelem(dev):
  349. """Wi-Fi Display and invalid subelement parsing"""
  350. addr1 = dev[1].p2p_dev_addr()
  351. try:
  352. enable_wifi_display(dev[0])
  353. enable_wifi_display(dev[1])
  354. dev[1].request("WFD_SUBELEM_SET 0 ffff00411c440028")
  355. dev[1].p2p_listen()
  356. dev[0].p2p_find(social=True)
  357. ev = dev[0].wait_global_event(["P2P-DEVICE-FOUND"], timeout=10)
  358. if ev is None:
  359. raise Exception("Device discovery timed out")
  360. if "wfd_dev_info=" in ev:
  361. raise Exception("Invalid WFD subelement was shown")
  362. finally:
  363. dev[0].request("SET wifi_display 0")
  364. dev[1].request("SET wifi_display 0")
  365. def test_wifi_display_parsing(dev):
  366. """Wi-Fi Display extensions to P2P and special parsing cases"""
  367. try:
  368. _test_wifi_display_parsing(dev)
  369. finally:
  370. dev[1].request("VENDOR_ELEM_REMOVE 11 *")
  371. dev[0].request("SET wifi_display 0")
  372. def _test_wifi_display_parsing(dev):
  373. wfd_devinfo = "00411c440028"
  374. dev[0].request("SET wifi_display 1")
  375. dev[0].request("WFD_SUBELEM_SET 0 0006" + wfd_devinfo)
  376. dev[0].p2p_start_go(freq=2412)
  377. # P2P Client with invalid WFD IE
  378. if "OK" not in dev[1].request("VENDOR_ELEM_ADD 11 dd10506f9a0a000000010000060000ffffff"):
  379. raise Exception("VENDOR_ELEM_ADD failed")
  380. pin = dev[1].wps_read_pin()
  381. dev[0].p2p_go_authorize_client(pin)
  382. dev[1].p2p_connect_group(dev[0].p2p_dev_addr(), pin, timeout=60,
  383. social=True, freq=2412)
  384. bssid = dev[0].get_group_status_field('bssid')
  385. dev[2].scan_for_bss(bssid, freq=2412, force_scan=True)
  386. bss = dev[2].get_bss(bssid)
  387. if bss['wfd_subelems'] != "000006" + wfd_devinfo:
  388. raise Exception("Unexpected WFD elements in scan results: " + bss['wfd_subelems'])
  389. # P2P Client without WFD IE
  390. pin = dev[2].wps_read_pin()
  391. dev[0].p2p_go_authorize_client(pin)
  392. dev[2].p2p_connect_group(dev[0].p2p_dev_addr(), pin, timeout=60,
  393. social=True, freq=2412)
  394. dev[2].remove_group()
  395. dev[0].remove_group()
  396. dev[1].wait_go_ending_session()
  397. def test_wifi_display_disable(dev):
  398. """Peer disabling Wi-Fi Display advertisement"""
  399. try:
  400. enable_wifi_display(dev[1])
  401. dev[1].p2p_listen()
  402. dev[0].p2p_find(social=True)
  403. ev = dev[0].wait_global_event(["P2P-DEVICE-FOUND"], timeout=15)
  404. if ev is None:
  405. raise Exception("Peer not found")
  406. if "wfd_dev_info" not in ev:
  407. raise Exception("Missing wfd_dev_info")
  408. dev[1].request("SET wifi_display 0")
  409. ev = dev[0].wait_global_event(["P2P-DEVICE-FOUND"], timeout=10)
  410. if ev is None:
  411. raise Exception("Peer update not indicated")
  412. if "new=0" not in ev:
  413. raise Exception("Incorrect update event: " + ev)
  414. if "wfd_dev_info" in ev:
  415. raise Exception("Unexpected wfd_dev_info")
  416. ev = dev[0].wait_global_event(["P2P-DEVICE-FOUND"], timeout=0.75)
  417. if ev is not None:
  418. raise Exception("Unexpected peer found event: " + ev)
  419. dev[0].p2p_stop_find()
  420. dev[1].p2p_stop_find()
  421. finally:
  422. dev[1].request("SET wifi_display 0")