p2p-group-formation.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/python
  2. #
  3. # P2P group formation test
  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 os
  9. import sys
  10. import time
  11. import logging
  12. from wpasupplicant import WpaSupplicant
  13. def main():
  14. if len(sys.argv) > 1 and sys.argv[1] == '-d':
  15. logging.basicConfig(level=logging.DEBUG)
  16. else:
  17. logging.basicConfig()
  18. dev0 = WpaSupplicant('wlan0')
  19. dev1 = WpaSupplicant('wlan1')
  20. dev0.request("hello")
  21. dev0.ping()
  22. if not dev0.ping() or not dev1.ping():
  23. print "No response from wpa_supplicant"
  24. return
  25. addr0 = dev0.p2p_dev_addr()
  26. addr1 = dev1.p2p_dev_addr()
  27. print "dev0 P2P Device Address: " + addr0
  28. print "dev1 P2P Device Address: " + addr1
  29. dev0.reset()
  30. dev1.reset()
  31. dev0.p2p_listen()
  32. dev1.p2p_listen()
  33. pin = dev0.wps_read_pin()
  34. dev0.p2p_go_neg_auth(addr1, pin, "display")
  35. print "Start GO negotiation"
  36. dev1.p2p_go_neg_init(addr0, pin, "enter", timeout=15)
  37. dev0.dump_monitor()
  38. dev1.dump_monitor()
  39. if __name__ == "__main__":
  40. main()