test_p2p_wifi_display.py 3.3 KB

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