wifi send raw packets



  • I am trying to send wifi packets from STA to AP using the wlan.send_raw API. I used two LoPy4, one configured as an AP and the other as an STA. They were connected successfully but I failed to send packets from STA. The wlan.send_raw API always reports an error of 'TypeError: wrong number of arguments'. Could someone please give me a quick example of how to correctly use the wlan.send_raw API? Many thanks.

    Please find my code for STA below.

    from network import WLAN
    import time
    import machine
    
    wlan = WLAN()
    
    # wlan.init(mode = WLAN.AP, ssid = 'my_ap', channel = 1, bandwidth=WLAN.HT20)
    
    wlan.init(mode = WLAN.STA, ssid = 'my_ap', bandwidth=WLAN.HT20)
    
    wlan.connect(ssid='my_ap')
    while not wlan.isconnected():
        machine.idle()
    print("WiFi connected succesfully")
    
    wlan.send_raw(Buffer=bytes('Hello'))
    


  • This post is deleted!


  • @gxshen said in wifi send raw packets:

    wlan.send_raw(Buffer=bytes('Hello'))

    You should use:
    wlan.send_raw(bytes('Hello'))

    The assignment Buffer=bytes('Hello')) does not create a suitable object. The other arguments have default values, but you could try to specify them.


Log in to reply
 

Pycom on Twitter