Question

How to obtain a Motorola (Symbol) Mobile Device Serial Number?

I'm programming the Motorola ES400 which comes with "Symbol" libraries.

There seems to be ways of getting the serial numbers of the various scanners, but not of the actual device itself!

Anyone got any ideas?


Whats the difference between "serial number" (as shown on the device) and "electronic serial number" returned by TerminalInfo?

Was it helpful?

Solution

I just dealt with this on the MC9090 device, which also uses the Symbol libraries (not sure if they are the same, but this is worth a shot). I used reflection because I have devices from different manufacturers and want the same code to run. You could access this field directly from the property or use reflection:

Here is where the property is:

Symbol.ResourceCoordination.Terminalinfo.ESN

Here is my method using reflection:

try
        {                   
                Assembly symbolApi = Assembly.LoadFrom("Symbol.ResourceCoordination.dll");      

                Type terminalInfo = null;

                foreach (Type t in symbolApi.GetTypes())
                {
                    if (t.Name == "TerminalInfo")
                    {
                        terminalInfo = t;                       
                        break;
                    }
                }

                LogService.log(terminalInfo.Name);

                if (terminalInfo != null)
                {
                    object objTerminalInfo = Activator.CreateInstance(terminalInfo);

                    PropertyInfo esn = null;
                    foreach (PropertyInfo info in terminalInfo.GetProperties())
                    {                           
                        if (info.Name == "ESN")
                        {
                            esn = info;
                            break;
                        }
                    }

                    if (esn != null)
                    {
                        object objSn = esn.GetValue(objTerminalInfo, null);
                        sn = objSn.ToString();
                    }
                }
                else
                    LogService.log("TerminalInfo type not found in " + symbolApi.FullName);

        }
        catch (MissingFieldException e)
        {               
            LogService.log("MissingFieldException, not Symbol Unit: " + e.Message);
        }
        catch (Exception e)
        {
            LogService.log("Error in SymbolAPI: " + e.Message);
        }

Hope this helps!

OTHER TIPS

Thats fantatic, thanks. The Symbol SDK help didn't find this when searching!

Just used:

Symbol.ResourceCoordination.TerminalInfo  Version = new Symbol.ResourceCoordination.TerminalInfo();

        return Version.ESN;

Also found this:

            Symbol.ResourceCoordination.TerminalInfo  Version = new Symbol.ResourceCoordination.TerminalInfo();

        System.Text.StringBuilder MyUUID = new StringBuilder("0x") ;

        if (Version.UniqueUnitID != null)
        {
            //this code is actually from the Motorola SDK guid 
            foreach (byte b in Version.UniqueUnitID)

                MyUUID.Append(b.ToString("X2"));

        }

        return MyUUID.ToString();

Here's the quick and easy VB.Net solution:

Add a reference to Symbol.ResourceCoordination.dll (I found mine here: C:\Program Files\Motorola EMDK for .NET\v2.8\SDK\Smart Devices\Symbol.ResourceCoordination.dll).

Then use the following code to access the ESN (Electronic Serial Number) value.

Dim Version As New Symbol.ResourceCoordination.TerminalInfo
MsgBox(Version.ESN)

Worked great on our MC3190S scanners! :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top