apiwindows-mobilemobilepocketpc

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


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?


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!