Forum Archive

WIFI SSID

inyourfaceplate

Hi there!

Can anyone show me how to access the current WIFI SSID via Pythonista? This would be awesome in the widget.

Thanks,
John

ccc

https://forum.omz-software.com/topic/3283/can-pythonista-change-settings-such-as-choosing-wifi-network

https://forums.developer.apple.com/thread/11807

NEHotspotHelper supportedNetworkInterfaces

cvp

It must be possible because the Launcher app allows to display it in its widget.

example

scj643

I think this requires a special app entitlement

cvp

I think you're right, as I´ve read

scj643

"Your program needs the com.apple.wifi.manager-access entitlement to use any of the WiFiManager functions."

http://iphonedevwiki.net/index.php/MobileWiFi.framework

omz

This works for me:

from objc_util import *

def get_ssid():
    CNCopyCurrentNetworkInfo = c.CNCopyCurrentNetworkInfo
    CNCopyCurrentNetworkInfo.restype = c_void_p
    CNCopyCurrentNetworkInfo.argtypes = [c_void_p]
    info = ObjCInstance(CNCopyCurrentNetworkInfo(ns('en0')))
    return str(info['SSID'])

print('Current SSID:', get_ssid())
cvp

I was almost sure it was possible since Apple did stop to depreciate this CNCopyCurrentNetworkInfo in ios10...

Thanks for @inyourfaceplate

scj643

@omz Ah a c function I'm going to have to remember that for my objc_tools network submodule

inyourfaceplate

omz's solution works great!

Thanks everyone!

vladimir_key

Hi @omz,
I found that your solution is not work anymore (ios 13.3.1). Its return "wifi" instead of correct name. Do you have ideas?

cvp

@vladimir_key omz solution works for me but you need iOS 13.3 and that you Pythonista app has permission to access your location (iOS 13 limitation)

See Discussion

Seems that if you receive "wi-fi", you should be in iOS 12

vladimir_key

Hi @cvp,
Thank you! Yep, it was location permission problem. Now its working and my iOS 13.3.1.

sammontalvo

For some unknown (for me) reason, I got this error message:
"No method found for selector "isKindOfClass:"

Any clue?

cvp

Same for me

omz

Looks to be some kind of internal bug in objc_util, though I don’t have an explanation right now.

cvp

@omz seems that CNCopyCurrentNetworkInfo(ns('en0')) returns nil like old bug before ios13.3

wnMark

For me it no longer works since Pythonista 3.3

omz

Could have something to do with the fact that 3.3 is built with the iOS 13 SDK.