0

I need to connect to a WiFi access point on android using Python script and SL4A. I looked at SL4A's documentation http://www.mithril.com.au/android/doc/WifiFacade.html but there is not function for connecting to and authenticating for a given AP. Is there a way around this?

Thanks in advance!

PS: I am actually looking for a suitable scripting language that can access all Android API, simple syntax would be a plus. The idea is that users can write simple scripts for tasks such as authenticating to a WiFi access point, launching an application or navigating to a URL in browser. But is seems SL4A is the only scripting platform available on Android.

flintlock
  • 97
  • 7

1 Answers1

0

New version of SL4A 6.2.0 (alpha status) can connect AP with new API: wifiConnect.

method = "no-security"
if method == "no-security":
    cfg = dict(
        SSID="invalidwifi",
        # below parameters are not used in example of my expalation site.
        # BSSID=,
        # hiddenSSID=False,
        # priority=,
        # apBand=,
    )
elif method == "WEP":
    cfg = dict(
        SSID="invalidwifi",
        wepKeys=["key0"],
        wepTxKeyIndex=0,
    )
else:   # elif method == "WPA2":
    cfg = dict(
        SSID="sample",
        password="abc",
        # preSharedKey="128bitkey.........",
        # or you can use: password="presharedkey",
        # be careful SL4A can't allow 64byte key.
    )
droid.wifiConnect(cfg)

I tested this code and new API. Please try it.

kuri65536
  • 166
  • 2
  • 8
  • Is the key name `password` (or `preSharedKey`) documented anywhere? In the [documentation](https://github.com/kuri65536/sl4a/blob/master/docs/ApiReference.md) the type is only documented as `JSONObject`. (In [Android API](https://developer.android.com/reference/android/net/wifi/WifiConfiguration) (java/Kotlin) the field name is `preSharedKey`.) – user202729 Dec 15 '20 at 04:57
  • I forget it this wrote in 4 years ago...search preSharedKey in SL4A repository, see this code: https://github.com/kuri65536/sl4a/commit/9628330f734fce1277e440e34074cad9cf39c538 – kuri65536 Dec 27 '20 at 22:11