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

主宰稳场 提交于 2020-01-04 03:14:11

问题


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?


回答1:


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!




回答2:


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;



回答3:


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();



回答4:


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! :)



来源:https://stackoverflow.com/questions/4570341/how-to-obtain-a-motorola-symbol-mobile-device-serial-number

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!