using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace Urovo { /// /// Provides access to the urovo i60xx serial handheld terminals. /// public class Device { /// /// 802.1X authentication mode /// public enum AuthMode { /// /// Specifies IEEE 802.11 Open System authentication mode /// Open, /// /// Specifies IEEE 802.11 Shared Key authentication mode /// Shared, /// /// Specifies WPA version 1 security for infrastructure mode /// WPA, /// /// Specifies WPA version 1 security (pre shared key) for infrastructure mode /// WPAPSK, /// /// Specifies WPA version 1 security for ad hoc mode /// WPANone, /// /// Specifies WPA version 2 security for infrastructure mode /// WPA2, /// /// Specifies WPA version 2 security (pre shared key) for infrastructure mode /// WPA2PSK } /// /// 802.1X encryption mode /// public enum EncryptMode { /// /// No WEP encryption /// Disabled, /// /// WEP encryption enabled /// WEP, /// /// TKIP encryption enabled /// TKIP, /// /// AES encryption enabled /// AES } /// /// 802.1X extensible authentication protocol type /// public enum EapType { /// /// EAP-TLS authentication /// TLS, /// /// PEAP authentication /// PEAP, /// /// MD5 authentication /// MD5 } /// /// Encapsulates information for a Wireless Local Area Network (WLAN) access point /// [StructLayout(LayoutKind.Sequential)] public class WlanInfo { /// /// Specifies a media access control (MAC) address. Each access point has a unique MAC address that is the same as the BSSID. /// [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] public byte[] MacAddress; /// /// The length of the Ssid member /// public uint SsidLength; /// /// The SSID /// [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] Ssid; /// /// The received signal strength indication (RSSI) in dBm /// public int Rssi; } /// /// This structure stores a list of WlanInfo structure. /// [StructLayout(LayoutKind.Sequential)] public class WlanInfoList { /// /// Number of items in the list of WlanInfo structures. /// public uint count; /// /// Point to an array of WlanInfo structures. /// public IntPtr pWlanInfo; } /// /// The type of the device information that is being requested /// public enum DeviceInfoType : uint { /// /// Determines whether a cold boot occurred. The pvParam parameter must point to a int variable that receives 0 if a cold boot occurred, or 1 if a warm boot occured. /// BootType = 1, } /// /// The triggering mode of the scanner. /// public enum TriggerMode { /// /// The laser is always on and decoding. /// Normal = 0, /// /// The laser is on when user press the "scan" key. /// Continuous } /// /// The type of the sms notification event. /// public enum SmsNotifyType : byte { /// /// Indicates that new message has been received /// NewSms = 0x10, /// /// Indicates that rssi has been received /// Rssi = 0x11, /// /// Indicates that the network status has changed /// RegistrationState = 0x12 } /// /// This function is used to power on the gsm module /// /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool EnableGsmModule(); /// /// This function is used to power off the gsm module /// /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool DisableGsmModule(); /// /// This function is used to get the power status of the gsm mudule /// /// 1 when gsm module is power on, 0 when power off, -1 when unknown [DllImport("Device.dll")] public static extern int GetGsmPowerStatus(); /// /// This function is used to request that the gsm module return the received signal strength indication (rssi) /// /// the rssi value. please see the remarks /// /// /// /// 0 /// -113 dBm or less /// /// /// 1 /// -111 dBm /// /// /// 2..30 /// -109...-53 dBm /// /// /// 31 /// -51 dBm or greater /// /// /// 99 /// not known or not detectable /// /// /// [DllImport("Device.dll")] public static extern int GetGsmSignalStrength(); /// /// This function is used to power on the wlan module /// /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool EnableWlanModule(); /// /// This function is used to power off the wlan module /// /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool DisableWlanModule(); /// /// This function is used to get the power status of the wlan module /// /// 1 when wlan module is power on, 0 when power off, -1 when unknown [DllImport("Device.dll")] public static extern int GetWlanPowerStatus(); /// /// This function is used to request that the wlan driver return the received signal strength indication (RSSI). /// /// the RSSI value in dBm. the normal values for the RSSI value are between -10 and -200 [DllImport("Device.dll")] public static extern int GetWlanSignalStrength(); /// /// This function is used to power on the bluetooth module /// /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool EnableBthModule(); /// /// This function is used to power off the bluetooth module /// /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool DisableBthModule(); /// /// get the power status of the Bluetooth module /// /// 1 when bluetooth module is power on, 0 when power off, -1 when unknown [DllImport("Device.dll")] public static extern int GetBthPowerStatus(); /// /// This function is used to power on the GPS module /// /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool EnableGpsModule(); /// /// This function is used to power off the GPS module /// /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool DisableGpsModule(); /// /// get the power status of the GPS module /// /// 1 when GPS module is power on, 0 when power off, -1 when unknown [DllImport("Device.dll")] public static extern int GetGpsPowerStatus(); /// /// This function is used to power on the vibrate module /// /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool EnableVibrateModule(); /// /// This function is used to power off the vibrate module /// /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool DisableVibrateModule(); /// /// This function is used to set the backlight value /// /// the backlight value ,range is 1~20 /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetBackLightLevel(int level); /// /// GetBackLightLevel /// /// Returns the backlight value. between 1-20. -1 indicates failed. [DllImport("Device.dll")] public static extern int GetBackLightLevel(); /// /// This function is used to Check that the device is connected to the gateway /// /// true when the device has connected to the gateway, false when not connected /// this function does not distinguish between network type(such as gprs, wireless lan, usb) [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool CheckNetworkStat(); /// /// This function is used to establishes a gprs connection /// /// a ras phone book entry name /// the Zero indicates success. A nonzero error value, either from the set listed in the RAS header file or ERROR_NOT_ENOUGH_MEMORY, indicates failure. /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool ConnectGprs([MarshalAs(UnmanagedType.LPWStr)]string connName, out uint errorCode); /// /// This function is used to check the gprs connection status /// /// a ras phone book entry name /// true when active, false when disactive [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GetGprsStatus([MarshalAs(UnmanagedType.LPWStr)]string connName); /// /// This function is used to terminate the gprs connection /// /// a ras phone book entry name [DllImport("Device.dll")] public static extern void DisConnectGprs([MarshalAs(UnmanagedType.LPWStr)]string connName); /// /// creates a new phone-book entry for gprs /// /// the string that contains an phone entry name /// the string that contains an acess point name /// the string that contains a telephone number /// the string that contains the user's user name. This string is used to authenticate the user's access to the remote access server. /// the string that contains the user's password. This string is used to authenticate the user's access to the remote access server. /// string that contains the domain on which authentication is to occur. An empty string ("") specifies the domain in which the remote access server is a member. An asterisk specifies the domain stored in the phone book for the entry. /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool CreateGprsEntry([MarshalAs(UnmanagedType.LPWStr)]string connName, [MarshalAs(UnmanagedType.LPWStr)]string apn, [MarshalAs(UnmanagedType.LPWStr)]string phoneNumber, [MarshalAs(UnmanagedType.LPWStr)]string userName, [MarshalAs(UnmanagedType.LPWStr)]string password, [MarshalAs(UnmanagedType.LPWStr)]string domain); /// /// This function provides detailed information for the Wireless NIC as they are cached in the driver . /// /// the media access control (MAC) address of the access point associated with the NIC. /// The list of the SSIDs detected by the NIC. /// The list of preferred wireless zero configurations /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool QueryWlanInformation(byte[] currentMac, WlanInfoList pAvailableList, WlanInfoList pPreferredList); /// /// This function is used to free the memory that was allocated by a call to QueryWlanInformation. /// [DllImport("Device.dll")] public static extern void FreeWlanInformation(); /// /// Add a SSID to the "preferred network list" /// /// the name of wireless network to connect /// 802.1x authentication mode /// 802.1x encryption mode /// /// for WEP-key, use 'key-index/key-value' format
/// 'key-index' is WEP key index(1-4), 'key-value' is WEP key value (40-bit or 104-bit).
/// 40-bit is either '10-digit hex numbers' (ex: "0x1234567890") or '5-char ASCII string' (ex: "zxcvb")
/// 104-bit is either '26-digit hex numbers' (ex: "0x12345678901234567890123") or '13-char ASCII string' (ex: "abcdefghijklm")
/// for TKIP-key, use 'key-value' format. (no key index)
/// TKIP-key can be 8-63 char ASCII string (ex: "asdfghjk") /// /// 802.1x EAP extension type. both AP and STA will get keys automatically after the successful EAP. /// indicates whether or not connecting to adhoc net /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool AddToWlanPreferredList([MarshalAs(UnmanagedType.LPWStr)]string szSSID, AuthMode authMode, EncryptMode encryptMode, [MarshalAs(UnmanagedType.LPWStr)]string szKey, EapType eapType, [MarshalAs(UnmanagedType.Bool)]bool bAdhoc); /// /// Clear the "preferred networks list". /// /// true indicates success, false indicates failure /// After a succ call, wireless card will disconnect if it was connected [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool ResetWlanPreferredList(); /// /// Forces the wireless card to reconnect "preferred networks list" /// /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool RefreshWlanPreferredList(); /// /// This functions is used to register power notification events.the developer can use these events to handle suspend of the device. /// /// suspend event /// notification event /// true indicates success, false indicates failure /// when the device is about to go into a suspended state, the suspend event is signaled. the developer can do someing, then set the state of the notification event to signaled to allow the device suspend. [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool RegisterPowerEvent(out IntPtr hSuspendEvent, out IntPtr hNotifyEvent); /// /// This functions is used to deregister the events that registered by a call to RegisterPowerEvent. /// /// suspend event /// notification event [DllImport("Device.dll")] public static extern void UnRegisterPowerEvent(IntPtr hSuspendEvent,IntPtr hNotifyEvent); /// /// This function is used to get the id of the device /// /// the buffer to store the device id /// the buffer length in characters, must be large than 14. /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GetDeviceID(StringBuilder deviceId, uint length); /// /// This function is used to receive the value of one of the device infomations /// /// The type of the device information that is being requested /// Depends on the device information being queried. For more information, see the DeviceInfoType enum /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GetDeviceInfo(DeviceInfoType deviceInfoType, out int pvParam); /// /// This function is used to set the mode of the keyboard. /// /// 0,numpad mode; 1,lowercase mode; 2,uppercase mode /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetKeyboardMode(uint uiMode); /// /// This function is used to query the mode of the keyboard. /// /// 0 when numpad mode, 1 when lowercase mode, 2 when uppercase mode [DllImport("Device.dll")] public static extern int GetKeyboardMode(); /// /// This function is used to enable the system cursor. /// /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool EnableCursor(); /// /// This function is used to enable the system cursor. /// /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool DisableCursor(); /// /// This function is used to enable the screen auto-lock. After call this method, the screen will be locked after a specified period of time expires. ther user can poress Fn+5 to unlock the screen. /// /// inteval time, in seconds /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool StartScreenLock(uint idleTime); //in seconds /// /// This function resets the timer that controls whether or not the screen will auto-lock. /// [DllImport("Device.dll")] public static extern void ScreenLockTimerReset(); /// /// This function is used to enable the screen auto-lock. /// [DllImport("Device.dll")] public static extern void StopScreenLock(); /// /// This function is used to check the screen status /// /// true when locked, false when not [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool IsScreenLocked(); /// /// This function is used to power on the scanner module /// /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SCA_EnableModule(); /// /// This function is used to power off the scanner module /// /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SCA_DisableModule(); /// /// This function is used to get the power status of the scanner module /// /// 1 when power on, 0 when power off, -1 when unknown [DllImport("Device.dll")] public static extern int SCA_GetPowerStatus(); /// /// This function is used to register for scan notification events. /// /// Handle to the application's message queue created with CreateMsgQueue /// Nonzero indicates success. Zero indicates failure /// Scan notification events are issued through message queues.
/// The developer can use ReadMsgQueue to read a single message from the message queue.
/// The first byte in each message indicates the barcode type. the second byte in each message indicates the length of the barcode. ///
[DllImport("Device.dll")] public static extern IntPtr SCA_RegisterNotification(IntPtr hMsgQ); /// /// This function is used to stop receiving scan notification events. /// /// The handle returned from SCA_RegisterNotification /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SCA_UnRegisterNotification(IntPtr hNotify); /// /// This function is used to trigger the laser /// /// true for laser on, false for laser off /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SCA_SetTriggerState([MarshalAs(UnmanagedType.Bool)]bool state); /// /// This function is used to set the trigger mode /// /// the supported trigger mode are listed in the TriggerMode enumeration /// true indicates success, false indicates failure /// the setting of the triggermode will be lost when power removed.
/// This function is only available on symbol scanner. ///
[DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SCA_SetTriggerMode(TriggerMode mode); /// /// This functions is used to send commands to the scanner. /// /// a buffer the contain the data of the commands /// the size of the buffer, in bytes /// Specifies whether or not the commands is lost when power down /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SCA_SendParam(byte[] pParam, uint dwSize, [MarshalAs(UnmanagedType.Bool)]bool bPermanent); /// /// This functions is used to request parameters of the scanner /// /// a buffer the contain the parameters name /// size of the pParam, in bytes /// a buffer that used to receive the parameter value /// size of the pParamVal, in bytes /// true indicates success, false indicates failure /// This function is only available on symbol scanner. [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SCA_RequestParam(byte[] pParam, uint dwSize, byte[] pParamVal, ref uint dwValSize); /// /// This function is used to set all parameters to their factory default settings. /// /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SCA_ResetScannerParams(); /// /// This function is used to open the sms function of the device /// /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SMS_Open(); /// /// This function is used to close the sms function of the device /// [DllImport("Device.dll")] public static extern void SMS_Close(); /// /// This function is used to determine whether the sms function is opened. /// /// true indicates the sms function is opened. false indicates not [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SMS_IsOpened(); /// /// This function is used to register for sms notification events. /// /// Handle to the application's message queue created with CreateMsgQueue /// Nonzero indicates success. Zero indicates failure /// sms notification events are issued through message queues.
/// The developer can use ReadMsgQueue to read a single message from the message queue.
/// The first byte in each message indicates the notify type. the second byte in each message contain the valid data. ///
[DllImport("Device.dll")] public static extern IntPtr SMS_RegisterNotification(IntPtr hMsgQ); /// /// This function is used to stop receiving the sms notification events. /// /// The handle returned from SMS_UnRegisterNotification /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SMS_UnRegisterNotification(IntPtr hNotify); /// /// This function is used to send a SMS message.New applications should call SMS_SendSMSEx instead of this function. /// /// The phone number of the recipient /// The phone number of the short message service senter, this param can be empty /// The content of the short message. it can be up to 160 characters (7 bit coded ) or 140 characters (8 bit coded) or 70 characters(unicode) /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SMS_SendSMS([MarshalAs(UnmanagedType.LPWStr)]string szRecipient, [MarshalAs(UnmanagedType.LPWStr)]string szSmsc, [MarshalAs(UnmanagedType.LPWStr)]string szMsg); /// /// This function is used to send a SMS message. /// /// The phone number of the recipient /// The phone number of the short message service senter, this param can be empty /// The content of the short message. it can be up to 160 characters (7 bit coded ) or 140 characters (8 bit coded) or 70 characters(unicode) /// The reference number of the enhanced concatenated short message /// The maximum number of short messages in the enhanced concatenated short message. /// The sequence number of the current short message. /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SMS_SendSMSEx([MarshalAs(UnmanagedType.LPWStr)]string szRecipient, [MarshalAs(UnmanagedType.LPWStr)]string szSmsc, [MarshalAs(UnmanagedType.LPWStr)]string szMsg, ushort wID, byte byTotalNum, byte byCurrentNum); /// /// This function is used to Read a SMS messages from preferred store.New applications should call SMS_ReadSMSEx instead of this function. /// /// Integer type; value in the range of location numbers supported by the associated memory /// a buffer to receive the phone number of the recipient /// the size of the recipient buffer, in characters /// a buffer to receive the content of the message /// the size of the message content buffer, in characters /// a buffer to receive the time of the message /// the size of the time buffer, in characters /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SMS_ReadSMS(int iIndex, StringBuilder szRecipient, uint dwRecpLen, StringBuilder szMsg, uint dwMsgLen, StringBuilder szTime, uint dwTimeLen); /// /// This function is used to Read a SMS messages from preferred store. /// /// Integer type; value in the range of location numbers supported by the associated memory /// a buffer to receive the phone number of the recipient /// the size of the recipient buffer, in characters /// a buffer to receive the content of the message /// the size of the message content buffer, in characters /// a buffer to receive the time of the message /// the size of the time buffer, in characters /// The reference number of the enhanced concatenated short message /// The maximum number of short messages in the enhanced concatenated short message. /// The sequence number of the current short message. /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SMS_ReadSMSEx(int iIndex, StringBuilder szRecipient, uint dwRecpLen, StringBuilder szMsg, uint dwMsgLen, StringBuilder szTime, uint dwTimeLen, ref ushort pwID, ref byte pbyTotalNum, ref byte pbyCurrentNum); /// /// This function is used to delete a SMS messages from preferred store. /// /// Integer type; value in the range of location numbers supported by the associated memory /// true indicates success, false indicates failure [DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SMS_DeleteSMS(int iIndex); /// /// This function is used to list SMS messages from preferred store. /// /// true indicates success, false indicates failure /// sms notification events are issued through message queues.
/// The first byte in each message indicates the notify type. the second byte in each message contain the sms index. ///
[DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SMS_ListSMS(); /// /// This function is used to request the rssi. /// /// true indicates success, false indicates failure /// sms notification events are issued through message queues.
/// The first byte in each message indicates the notify type. the second byte in each message contain the rssi. /// /// /// 0 /// -113 dBm or less /// /// /// 1 /// -111 dBm /// /// /// 2..30 /// -109...-53 dBm /// /// /// 31 /// -51 dBm or greater /// /// /// 99 /// not known or not detectable /// /// ///
[DllImport("Device.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SMS_GetSignalStrength(); /// /// This function is used to get the network registration status. /// /// The network registration status ,please see the remarks /// /// /// /// 0 /// Not registered, device is currently not searching for new operator. /// /// /// 1 /// Registered to home network /// /// /// 2 /// Not registered, but device is currently searching for a new operator. /// /// /// 3 /// Registration denied /// /// /// 4 /// Unknown /// /// /// 5 /// Registered, roaming /// /// /// [DllImport("Device.dll")] public static extern int SMS_GetRegistrationState(); } }