Follow Up: Automating the Setup Process for Motorola Devices

Some time ago, I asked if anyone knew of a way to automate the setup process for Motorola devices. Judging by the absolute silence, either no-one has succeeded in this task or it's a well kept secret within the industry!

Well, I think I've cracked it!

One pre-requisite is these fantastic command line CE tools, you can download from; https://sites.google.com/a/essemer.com.au/www/windowsce ( http://www.essemer.com.au/ )

The other, is the "rapistart.exe" executable from Microsoft's Windows Mobile PowerToys ( http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=10601 )

Step 1:

You'll need a mobile application to set the wireless profile settings & export them to a reg file. We'll export these settings to the "\Application" folder so they survive a cold boot.

Module MotorolaSetWLANApp
Private _IPAddress As String
Private _SubnetMask As String
Private _SSID As String
Private _Passphrase As String

Private _SetIPSettings As Boolean = False

Public Sub Main(ByVal args As String())
If args.Length > 0 Then
For i As Integer = 0 To args.Length - 1
Select Case args(i).ToLower
Case "-ip"
'get IP settings
_IPAddress = args(i + 1)
_SetIPSettings = True
Case "-subnet"
_SubnetMask = args(i + 1)
Case "-ssid"
_SSID = args(i + 1)
Case "-passphrase"
_Passphrase = args(i + 1)
End Select
Next
End If

If _SetIPSettings Then
Using Settings As New Symbol.Fusion.WLAN.WLAN
Dim ProfileData As New Symbol.Fusion.WLAN.InfrastructureProfileData(_SSID, _SSID)
With ProfileData
.PowerMode = Symbol.Fusion.WLAN.PowerMode.FAST_POWER_SAVE
.TransmissionPower = Symbol.Fusion.WLAN.InfrastructureProfileData.TransmitPowerLevel.BSS_AUTO
.IPSettings.AddressingMode = Symbol.Fusion.WLAN.IPSettings.AddressingModes.STATIC
.IPSettings.IPAddress = _IPAddress
.IPSettings.SubnetMask = _SubnetMask
.SecurityType = Symbol.Fusion.WLAN.WLANSecurityType.SECURITY_WPA_PERSONAL
.Authentication.AuthenticationType = Symbol.Fusion.WLAN.Authentication.AuthenticationTypes.NONE
.Encryption.EncryptionType = Symbol.Fusion.WLAN.Encryption.EncryptionTypes.TKIP_PASSPH
.Encryption.PassPhrase = _Passphrase
End With
Settings.Profiles.DeleteAll()
Settings.Profiles.CreateInfrastructureProfile(ProfileData)
Settings.Profiles.ExportAll(Symbol.Fusion.FileFormat.REG_FILE, Symbol.Fusion.WLAN.Profiles.ExportImportOpMode.MULTIPLE_PROFILE, "\Application\", Guid.NewGuid.ToString & ".reg")
End Using
End If

'force close (possibly superfluous)
Application.Exit()
End Sub
End Module


Pay attention to the WLAN settings - this example relates to our infrastructure but yours may differ. Luckily, for English-speakers, the settings in the Fusion API closely resemble the options in the "Manage Profiles" option on the Motorola Fusion tray icon that is installed by default on most devices so it's quite easy to work out what your settings should be if you have successfully configured the device using the Motorola UI.

From here, it's pretty straightforward. You simply need to run the application on the device with the correct settings passed in. This is where those CE tools come in. I copied all these tools to a folder names "tools" in our deployment application. From here, I can copy the executable I just made to the device and execute it with the arguments I need to.


Private Sub RunWait(ByVal App As String, ByVal Args As String)
Dim AppProcess As System.Diagnostics.Process
AppProcess = New System.Diagnostics.Process()
AppProcess.StartInfo.FileName = App
AppProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal
AppProcess.StartInfo.Arguments = Args
If AppProcess.Start() Then
'Wait until the process passes back an exit code
AppProcess.WaitForExit()
End If
'Free resources associated with this process
AppProcess.Close()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'copy application to device
RunWait(ToolsDir & "cecopy.exe", "/IS " & ToolsDir & "MotorolaSetWLan.exe dev:\application")
'execute app on device
RunWait(ToolsDir & "rapistart.exe", "\application\MotorolaSetWLan.exe -ip 123.123.123.123 -subnet 255.255.252.0 -ssid WLAN -passphrase password")

End Sub


I'm sure you can elaborate some pretty cool solutions from this, I'm planning a one-click deployment process for our IT Support desk to deploy quickly. Although our applications update over-the-air, Motorola hotfixes and EMDK updates currently require a lot of work to organise the upgrade - this tool will simplify the process. We also recycle devices for different purposes across the business - again, this tool will help us quickly reconfigure our devices for use in other areas of the business quickly.

Comments

  1. I know this is pretty old, but did you ever happen to find a way to decode/de-obfuscate the profiles rather than just loading the details & exporting the profile?

    ReplyDelete
  2. To be honest, once I managed to do it this way I stopped trying. My worry is that the files the device will export could change over time whereas theoretically, the API used above shouldn't change even if the file format does. (Although I am currently rewriting a lot of code for the new Symbol.Barcode2 classes so I suppose I should stop being so naive!)

    ReplyDelete
  3. I am not familiar with this programming language and therefore cannot compile it. I am in need of a way to automate the WLAN profile setup for Motorola MC50s and MC55's. Is there a way you could upload a binary of this utility? Thanks

    ReplyDelete
    Replies
    1. Hello,

      Are you using static IP addresses that you want to assign or is your network DHCP?

      The above process is for static IP addresses, there is a much easier way to automate this if you are using DHCP settings

      Regards,
      Will

      Delete
  4. Nevermind, it looks like all I needed was a copy of Visual Studio 2008 and the Motorola/Symbol/Zebra EMDK. I just needed to add a few references for the Symbol libraries in VS and was able to successfully compile the code.

    This code has been very useful to me. I used your code as a template to build my own wireless profile provisioning tool for these PDAs. I added a bunch of code to handle setting most of the other profile settings and so far have gotten it working pretty well with MC55A0s, N0s and 90s.

    I haven't touched VB since I was a kid back in the 90s but I've been able to pick it back up very quickly. It seems like the syntax hasn't really changed all that much since the old days.

    One thing I'm still not sure how to do is how to set the various adapter settings (not profile-specific) such as the adapter operating mode. I found a property that appears to be used to return the current opmode (Symbol.Fusion.WLAN.Adapter.SSIDInfo.OpMode) but since it is read-only I can't seem to use it to set it (unless perhaps I am doing this wrong.) I tried setting it like so:

    Symbol.Fusion.WLAN.Adapter.SSIDInfo.OpMode = Adapter.WLANNetworkType.NDIS802_11INFRASTRUCTURE

    However this causes VS to return the error message "Property 'OpMode' is 'Read Only'"

    Do you happen to know the proper way to set the opmode? One alternative I've been considering is just manually setting it on the PDA and then exporting the registry keys using the "Export" feature on the adapter "Options" menu. Then I'd just need to add some code to the application to import these registry keys when needed. I was just wondering if there is a way to do this directly in the code rather than relying on exported registry keys from the adapter options menu.

    I'd appreciate your feedback on this.

    Thanks

    ReplyDelete
    Replies
    1. Apologies, I had this on my list to respond to but never got round to it.

      I'm not 100% sure what the infrastructure mode is (especially outside of the Motorola ecosystem) but it has always appeared to be the default over the adhoc infrastructure mode. If you leave it without setting it, does this not do the same trick?

      Alternatively, you could set the WiFi up, export the config then just change the IP and re-export the config.

      Worth noting that newer models don't need the export step - they handle the persistence automatically.

      Delete
    2. Just looking over the old code. I suspect this property is readonly because you are creating an infrastructure profile here (as indicated in the class name InfrastructureProfileData)

      I suspect that if you wanted to create an ad-hoc connection, you'd need to use a different class with different properties for that connection. I suspect the infrastructure choice is made by the instantiation of the class.

      Hope that makes sense

      Delete

Post a Comment