Post 43 made on Sunday October 4, 2015 at 13:38 |
Lyndel McGee RC Moderator |
Joined: Posts: | August 2001 12,999 |
|
|
If you are familiar with JavaScript and have the latest firmware (7.2.4 or higher) on your machine, you can see the dev guide for the System Class.
A.12.1.11. System.getNetlinkStatus() (available since application version 7.2.4) Synopsis System.getNetlinkStatus() Purpose Obtain the control panel's network interface status. Parameters None. Return String Either “disabled”, “sleeping”, “wifi-disconnected”, “wifi-noip”, “wifi-standalone”, “wifi-level1”, “wifi-level2”, “wifi-level3”, “wifi-level4”, “ethdisconnected”, “eth-noip” or “eth-ok”.
Note that you can also add event listeners to the wifi status and will get a callback when it drops. Once you stop Wi-Fi, you may have add an event listener again. You will need to test this to see if it requires re-registration for events. Also note that I have only supplied addEventListener below. In order to play well with the system, if you call add a second time, always remove the previous registration by calling System.removeEventListener().
A.12.1.1. System.addEventListener()
(available since application version 7.2.4)
Synopsis System.addEventListener(type,listener)
Purpose Registers a function to be called for a class of system events.
Parameters type String Type of events to listen for. Valid types are “battery"” and “netlink”. listener systemEventListener
When you create a callback, you would do so like this.
A.12.2.1. systemEventListener Purpose Called when a system event occurs, if registered with System.addEventListener() . Parameters event String The new state caused by the event. For event listeners registered for “battery” events, this is the value which would be retrieved with the getBatteryStatus() method. For event listeners registered for “netlink” events, this is the value which would be retrieved with the get- NetlinkStatus() method.
For testing purposes, add this code to either the Activity Script or Page Script.
function wifiChanged(newState) { // here, newState is a string as documented in the DEV Guide. // write your code to act accordingly. // Either “disabled”, “sleeping”, “wifi-disconnected”, “wifi-noip”, // “wifi-standalone”, “wifi-level1”, “wifi-level2”, “wifi-level3”, // “wifi-level4”, “ethdisconnected”,“eth-noip” or “eth-ok”.
/* one or more of the target states you want/* if ('wifi-disconnected,wifi-noip'.indexOf(newState) >=0 ) { // remove listener so don't get 2nd callback when you disable. System.removeEventListener('netlink', wifiChanged); CF.activity().wifiEnabled = false; CF.activity().wifiEnabled = true; System.addEventListener('netlink', wifiChanged); } } System.addEventListener('netlink', wifiChanged);
|
|
Lyndel McGee Philips Pronto Addict/Beta Tester
|
|