Connecting to a specific SSID via command/script

Solved
R
Remy
Zollner Elektronik AG

Hi,

I am keen to hear if anyone knows how it is possible, via a script, to initiate the connection of a device to an SSID that already has a profile created on the device, but is different from the one the device is currently connected to.

10 months ago
SOTI MobiControl
ANSWERS
RS
Rafael Schäfer
10 months ago

No, it's not.

We had similar requests to Soti support (our TAM) in the past but the only way was to delete all other known ssid's (bad idea) or if you are on Mobicontrol 2024+ to redeploy the wifi profile with the "Set as Active Network" enabled which force (re-)connects all assigned devices once to this SSID (also not a good idea).

R
Remy
10 months ago

This doesn’t sound good at all...in a multi-SSID environment, there’s practically not much you can do in this regard.

R
Remy
10 months ago

Do you happen to know if at least prioritization is possible?

TG
Thomas G.
10 months ago

Hi, its possible by JavaScript. The documentation is here:
https://www.soti.net/mc/help/javascriptapi/en/mobicontrol.wifi.html

R
Remy
10 months ago

Hi Thomas,

more precisely, how exactly would you do it? Is JavaScript integrable into a Signal policy?

R
Remy
10 months ago

Unfortunately, a Java script cannot be initiated by the device through a Signal policy.

RS
Rafael Schäfer
10 months ago

It's not as you can just deploy again the already known SSID with the relevant settings and because of deploying that it can be that it connects to it but there's no "connect to" or so available in JS just pointing to a SSID to connect to like by Name or so without providing any additional connection information which are already stored on the device.

TG
Thomas G.
10 months ago

as Remy wrote "to initiate the connection of a device to an SSID that already has a profile created on the device, but is different from the one the device is currently connected to"
i assumed that there is more than 1 SSIDs configured and available in "Saved Networks"

With this small JS script, i am able to switch to any configured SSID on my device:

var ProdAP = mobicontrol.wifi.listAccessPoints().find(ap => ap.ssid == 'SSID-i-want-to-connect');
     mobicontrol.wifi.enable(ProdAP);     


Solution
R
Remy
10 months ago

almost there...Custom log (WifiError: Location services are off. (UserScript#1))

HV
Henk, van Asselt
10 months ago

For the WifiError: Location services are off, I did raise a ticket in May 2024, as you will see the same error if you use mobicontrol.wifi.uninstall().
I fail to understand the relationship between Location services and these script commands.
Also, and that is another ticket: It is not possible to run Locations services on with MobiControl.

R
Remy
10 months ago

Could you please tell me which ecosystems you encountered this issue with? Honeywell, Zebra, etc.

R
Remy
10 months ago

It worked! However, I’m not sure if this setting can be automated without direct interaction with the device...

Are there any opinions/solutions on this?

TG
Thomas G.
10 months ago

this should be done by a FeatureControl policy -> Location Accuracy -> you need "Battery Saving" at least (this way its working on our devices)

R
Remy
10 months ago

TG
Thomas G.
10 months ago

thats a bit strange, on my devices (AE Work Managed, different OEMs and OS versions) this works without  issue. If the profile was installed without error message you should contact SOTI's Support Team, maybe also check the logs in the console and also the agent activity log 

R
Remy
10 months ago

Can I ask if you have Honeywell devices among them?

R
Remy
10 months ago

Thomas, could you please indicate how you managed to resolve the issue on your end, given that others are also facing this problem?

R
Remy
10 months ago

I notice that the issue has already been reported, although for a different use case...https://discussions.soti.net/discussions/cannot-remove-a-wifi-network-with-javascript-mobicontrol-wifi-uninstall

R
Remy
10 months ago

For moderators! Could someone provide a definitive resolution to clearly outline the situation we are facing, ensuring all interested parties are informed?

R
Remy
10 months ago
Google Location Accuracy
 
 
 
 
  • <?xml version="1.0" encoding="UTF-8"?>
  • <ConfigDoc name="DeviceConfig">
    • <Section name="Personal">
      • <Section name="Location">
        • <Key name="Google Location Accuracy">1</Key>
        </Section>
      </Section>
    </ConfigDoc>
 
RS
Rafael Schäfer
10 months ago

That's interesting as i thought this would just enable them (allow them to connect to automatically)but not a force connect to them and our question to support even stated nothing in that direction. I'll give that a try as well.

R
Remy
10 months ago

Rafael, I understand you have Honeywell devices in your fleet. Could you confirm whether the location functionality is working or not? Thanks!

RS
Rafael Schäfer
10 months ago

No sorry, the sorting here is horrible. I answered to the response from Thomas G as i wonder that his script will do something different than expected.

But i can confirm, even from my end unexpected, the script from Thomas G. above works quite well at least on our devices (we don't have Honeywell devices).

MD
Matt Dermody Diamond Contributor
10 months ago

I can also confirm the script works well on my end. I've tested it on Zebra A13 devices so far.

R
Remy
10 months ago

Hi Matt,

If possible, please try it on a Honeywell device as well. I’m interested in the issue related to the location settings.

TG
Thomas G.
10 months ago

Hi, we also use HSM devices. But we do not configure 'Location Accuracy' with Honeywell's Enterprise Provisioner (or any other OEM tools), only by SOTI's FC Policy. 

R
Remy
10 months ago

Hi Thomas,

Thank you for the feedback!

Could I kindly ask you to specify which device families (model/build) you are referring to?

TG
Thomas G.
10 months ago

I just tested it on two CT40XP with Android 9 & 12, works for both without issue. If i set "High Accuracy",  access to location setting is blocked by admin and i see that Google apps like PlayStore and YouTube are using location service. If i set "Allow user to configure" access to location is possible for the device user and you can switch it on / off.  Also the script is working.

R
Remy
10 months ago

So, the automation functions until the moment the device user manually intervenes to change the setting in question?

ZC
Zafer Cigdem
10 months ago

Hi Remy,

I don't have Honeywel device with me, but I did use a JS script earlier with Samsung and Zebra devices well to overwrite WiFi SSID or connect a new SSID, I'm not sure did you use a similar JS library for your test earlier, but here is my JS that I've created about 2 years ago. I've used to get the information from device side for the WiFi credential but you can directly use it on your script as well instead of reading them from JSON

If you need any help you can let me know.


It's available for Agent version of 15.4.0+

First create a JSON file that consist of SSID and password of the WiFi, and save this file on the device path; for this example it is saved at /sdcard/download/readzafer.json location (name of this json file is "readzafer.json" for this case). The content of the JSON file may be as follows:


{

    "password": "wifipassword_here",

    "ssid": "SSIDname_here"

}


And send below JS Script to device:


var wifiConfigJSON = new mobicontrol.io.File('/sdcard/download/readzafer.json');

var jsonString = wifiConfigJSON.readText();

var wifiConfigString = JSON.parse(jsonString, mobicontrol.json.revive);

mobicontrol.message.createInfoDialog("SSID:" + wifiConfigString.ssid).show();

mobicontrol.message.createInfoDialog("password:" + wifiConfigString.password).show();

var wifiConfig = mobicontrol.wifi.createWifiConfiguration(wifiConfigString.ssid).withWpaSecurity(wifiConfigString.password);

mobicontrol.wifi.install(wifiConfig);

var accessPoint = mobicontrol.wifi.listAccessPoints().find(ap => ap.ssid == wifiConfigString.ssid);

mobicontrol.wifi.enable(accessPoint)


I hope it helps

Zafer

A
ATMOD@SOTI
9 months ago

Hi Remy,

 

Thanks for posting on SOTI Pulse.  If this post did not assist you in resolving the issue completely and you have additional questions, please do not hesitate to reach out or you can contact SOTI Support (support@soti.net) to open a new case and one of our support engineer will be there to assist you.

 

Kind Regards,

Technical Support | SOTI Inc. |1.905.624.9828 | support@soti.net | www.soti.net |

Similar Discussions