The PyS60 module autoAP may be used to automatically select the most suitable WLAN or cellular access point available at the moment. The autoAP module requires external PyS60 modules
The autoAP module is supposed to work in Nokia 3rd edition terminals supporting WLAN and GPRS/3G access (tested in Nokia E61i).
Questions, comments etc are welcome! Latest version available at http://www.iki.fi/lasse/mobile/python
At least for time being the autoAP module must be signed with DevCert.
>>> import autoap >>> nws = autoap.NetworkSelector() >>> nws.setSelectionCriteria(criteria) #= This is optional, see below! >>> status = nws.openNetworkConnection(): >>> if status == True: ... < do your stuff here, e.g. open http connection to somewehere > ... nws.closeNetworkConnection() >>> Note: openNetworkConnection() return True on success and False on failure.
Optionally it is possible to specify the network selection criteria before opening the network connection. The selection criteria is a list that defines rules how to select the network. The network selector first tries to select the network according to the first item in the list. If the connection could not be opened the next item is considered etc.
By default the criteria is such that if any configured WLAN network is seen then use it. If now WLANs are available then try to use GPRS/3G access point that offers internet access (access point name contains 'internet'). The list items are tuples and the content depends on the access type WLAN or cellular.
For WLAN networks:
select any available WLAN network configured to the terminal
('WLAN', apinfo.WLAN_ANY_AP)
select WLAN network with a given SSID
('WLAN', 'NetworkSSID')
For GPRS/3G networks:
generally
('CELL', , )
internet access point in any cellular network
('CELL', apinfo.CELL_INTERNET_ONLY_AP, [])
access point acmeintra in Sonera's network
('CELL', 'acmeintra', ['SONERA'])
For example, select WLAN having SSID 'acme_net', then any WLAN, and finally
the internet access point if in Sonera's network:
criteria = [('WLAN', 'acme_net'), ('WLAN', apinfo.WLAN_ANY_AP),
('CELL', apinfo.CELL_INTERNET_ONLY_AP, ['SONERA'])]
For more examples, see the end of the file autoap.py.