test_p2p_wifi_display.py 3.2 KB

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