Scan2Deploy: how to deploy json file with ADB intent?

Hello

Following the links here:

I have created a json file that i want to import into a device by adb settings.

I tried to import it with these 2 intent commands but with no succes:

adb shell am broadcast -a datalogic.scan2deploy.intent.action.START_SERVICE -n “com.datalogic.scan2deploy/.S2dServiceReceiver” --es encoding json --es json-path /sdcard/File.json

adb shell am start -S -n com.datalogic.scan2deploy/.MainActivity -e json-path /sdcard/File.json

Can you help me get the good adb command so i can import a json file into a device ?

The goal here is to modify some json file (like for Static IP in WiFi configuration) before importing them.

Regards.
Arnaud

Hello @SSE_MOBILITY,

Welcome to our forum!

adb shell am start -S -n com.datalogic.scan2deploy/.MainActivity -e json-path /sdcard/File.json

Using a JSON file is actually not supported from the MainActivity, so this will not work.

adb shell am broadcast -a datalogic.scan2deploy.intent.action.START_SERVICE -n “com.datalogic.scan2deploy/.S2dServiceReceiver” --es encoding json --es json-path /sdcard/File.json

After placing a JSON at the specified location, I copy and pasted this command and it worked.
The most likely reason that this would not be working is if the UI of Scan2Deploy Agent is open.
To close the UI of Agent, press the square button on your navigation bar, find Agent and drag it up.
Or run adb shell pm clear com.datalogic.scan2deploy

Drew Hugentobler
L3 Mobile Computer Specialist Support Engineer

2 Likes

Hi Arnoud,

In addition to Drews answer have a look at this (not official tool);

The version 7.2 and higher have support for automatic copy and launching S2DS json files.

Gr Peter

1 Like

Hey
Thanks for the answer, i didn’t see the anwser before today.

my point was trying to import a json file containing this:

{
“network”: {
“essid”: “SSID-Test”,
“mode”: “wpa-psk”,
“mode-key”: “Test1234”,
“ip-address”: “192.16.2.10”,
“ip-prefix-length”: 24,
“ip-gateway”: “192.16.2.1”,
“ip-dns1”: “8.8.8.8”,
“ip-dns2”: “8.8.4.4”
}
}

So i can import a SSID with static IP.
but it doesn’t work with any of the solution provided :frowning:

Hi @SSE_MOBILITY,

I would advise you to build the json file with Scan2Deploy Studio. It has the option to save as a json file. (Not that I see any mistakes in your file though)

I used the intent below:

adb shell am broadcast -a datalogic.scan2deploy.intent.action.START_SERVICE -n "com.datalogic.scan2deploy/.S2dServiceReceiver" --es json-path "sdcard/File.json" 

My JSON looked like this:

{
  "$schema": "https://raw.githubusercontent.com/datalogic/scan2deploy-android-schema/v1-22-0/schema.json",
  "network": {
    "essid": "SSID-Test",
    "mode": "wpa-psk",
    "mode-key": "Test1234",
    "ip-address": "192.16.2.10",
    "ip-prefix-length": 24,
    "ip-gateway": "192.16.2.1",
    "ip-dns1": "8.8.8.8",
    "ip-dns2": "8.8.4.4",
    "purge": false
  }
}

Alternatively you can use this command that embeds the json file in your string:

am broadcast -a datalogic.scan2deploy.intent.action.START_SERVICE -n "com.datalogic.scan2deploy/.S2dServiceReceiver" --es encoding json --es data "{\"$schema\":\"https://raw.githubusercontent.com/datalogic/scan2deploy-android-schema/v1-22-0/schema.json\",\"network\":{\"essid\":\"SSID-Test\",\"mode\":\"wpa-psk\",\"mode-key\":\"Test1234\",\"ip-address\":\"192.16.2.10\",\"ip-prefix-length\":24,\"ip-gateway\":\"192.16.2.1\",\"ip-dns1\":\"8.8.8.8\",\"ip-dns2\":\"8.8.4.4\",\"purge\":false}}"

(use the copy to JSON data (no whitespace)

Let us know if it works! Make sure as Drew said that the Scan2Deploy agent is not running on your device before sending the intent.

Gr Peter

1 Like

Hi Peter,
with your comand it works !

the difference between yours and Drew is " -es encoding json" .
Without it, the json file for my SSID is correctly interpredted !
Many thanks

2 Likes