test_p2p_wifi_display.py 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. import logging
  7. logger = logging.getLogger()
  8. import time
  9. import threading
  10. import Queue
  11. import hwsim_utils
  12. import utils
  13. def test_wifi_display(dev):
  14. """Wi-Fi Display extensions to P2P"""
  15. wfd_devinfo = "00011c440028"
  16. dev[0].request("SET wifi_display 1")
  17. dev[0].request("WFD_SUBELEM_SET 0 0006" + wfd_devinfo)
  18. if wfd_devinfo not in dev[0].request("WFD_SUBELEM_GET 0"):
  19. raise Exception("Could not fetch back configured subelement")
  20. wfd_devinfo2 = "00001c440028"
  21. dev[1].request("SET wifi_display 1")
  22. dev[1].request("WFD_SUBELEM_SET 0 0006" + wfd_devinfo2)
  23. if wfd_devinfo2 not in dev[1].request("WFD_SUBELEM_GET 0"):
  24. raise Exception("Could not fetch back configured subelement")
  25. dev[0].p2p_listen()
  26. dev[1].p2p_find(social=True)
  27. ev = dev[1].wait_event(["P2P-DEVICE-FOUND"], timeout=5)
  28. if ev is None:
  29. raise Exception("Device discovery timed out")
  30. if "wfd_dev_info=0x" + wfd_devinfo not in ev:
  31. raise Exception("Wi-Fi Display Info not in P2P-DEVICE-FOUND event")
  32. pin = dev[0].wps_read_pin()
  33. dev[0].p2p_go_neg_auth(dev[1].p2p_dev_addr(), pin, 'display')
  34. res1 = dev[1].p2p_go_neg_init(dev[0].p2p_dev_addr(), pin, 'enter', timeout=20, go_intent=15)
  35. res2 = dev[0].p2p_go_neg_auth_result()
  36. bss = dev[0].get_bss("p2p_dev_addr=" + dev[1].p2p_dev_addr())
  37. if bss['bssid'] != dev[1].p2p_interface_addr():
  38. raise Exception("Unexpected BSSID in the BSS entry for the GO")
  39. if wfd_devinfo2 not in bss['wfd_subelems']:
  40. raise Exception("Could not see wfd_subelems in GO's BSS entry")
  41. peer = dev[0].get_peer(dev[1].p2p_dev_addr())
  42. if wfd_devinfo2 not in peer['wfd_subelems']:
  43. raise Exception("Could not see wfd_subelems in GO's peer entry")
  44. peer = dev[1].get_peer(dev[0].p2p_dev_addr())
  45. if wfd_devinfo not in peer['wfd_subelems']:
  46. raise Exception("Could not see wfd_subelems in client's peer entry")
  47. wfd_devinfo3 = "00001c440028"
  48. dev[2].request("SET wifi_display 1")
  49. dev[2].request("WFD_SUBELEM_SET 0 0006" + wfd_devinfo3)
  50. dev[2].p2p_find(social=True)
  51. ev = dev[2].wait_event(["P2P-DEVICE-FOUND"], timeout=5)
  52. if ev is None:
  53. raise Exception("Device discovery timed out")
  54. if dev[1].p2p_dev_addr() not in ev:
  55. ev = dev[2].wait_event(["P2P-DEVICE-FOUND"], timeout=5)
  56. if ev is None:
  57. raise Exception("Device discovery timed out")
  58. if dev[1].p2p_dev_addr() not in ev:
  59. raise Exception("Could not discover GO")
  60. if "wfd_dev_info=0x" + wfd_devinfo2 not in ev:
  61. raise Exception("Wi-Fi Display Info not in P2P-DEVICE-FOUND event")
  62. bss = dev[2].get_bss("p2p_dev_addr=" + dev[1].p2p_dev_addr())
  63. if bss['bssid'] != dev[1].p2p_interface_addr():
  64. raise Exception("Unexpected BSSID in the BSS entry for the GO")
  65. if wfd_devinfo2 not in bss['wfd_subelems']:
  66. raise Exception("Could not see wfd_subelems in GO's BSS entry")
  67. peer = dev[2].get_peer(dev[1].p2p_dev_addr())
  68. if wfd_devinfo2 not in peer['wfd_subelems']:
  69. raise Exception("Could not see wfd_subelems in GO's peer entry")