Click or drag to resize

GsmModem Class

GSM modem component library that communicates with a GSM modem or phone with integrated modem. This component works with AT(Hayes) compliant GSM modems connected to one of the serial ports.You can use it also with USB, IrDA and bluetooth devices, because these devices have a driver that redirects the input from the USB, IrDA or bluetooth port to a virtual serial port (you can check it in System/Device Manager/Modems). To use with Android smart phones, you have to install the USB drivers first, activate USB debugging and connect it with USB cable as transferring files.
Inheritance Hierarchy

Namespace: ZylSoft.Gsm
Assembly: ZylGsm (in ZylGsm.dll) Version: 1.2.0.21451
XMLNS for XAML: Not mapped to an xmlns.
Syntax
public class GsmModem : Component

The GsmModem type exposes the following members.

Constructors
 NameDescription
Public methodGsmModem Constructor.
Public methodGsmModem(IContainer) Constructor.
Public methodGsmModem(SerialCommPort) Constructor.
Public methodGsmModem(SerialCommPort, SerialBaudRate) Constructor.
Top
Properties
 NameDescription
Public propertyAutoReadNewMessage If this property is true (default value), then new incoming messages are read automatically and after this, their status will be set to "received read message" (ReadMessage event).
Public propertyAutoReconnect Set this property to true, if you want to automatically reconnect to the serial port after a Faulted event, when the port is available again. Set AutoReconnect to true, before the port is faulted, otherwise it will have no effect. The default value is false.
Public propertyAutoReconnectCheckInterval The time interval in milliseconds the serial port is trying to periodically reconnect, after a Faulted event occur, if AutoReconnect is set to true. It must be a positive value. The default value is 4000.
Public propertyBaudRate Baud rate at which the communications device operates.
Protected propertyCanRaiseEventsGets a value indicating whether the component can raise an event.
(Inherited from Component)
Public propertyCloseWhenLineStatusIsZero When this property is true and line status becomes 0 (supposing that it was non 0 after the port has been opened), the port will be closed automatically. Set it to true, for improved fault detection. If you have problems with the port closing itself automatically immediately after open, set this property to false. The default value is true.
Public propertyConnectedTo Returns the physical port where the component is connected to.
Public propertyConnectionTime Indicates when the last connection was established.
Public propertyContainerGets the IContainer that contains the Component.
(Inherited from Component)
Public propertyCustomBaudRate Custom baud rate value, used when BaudRate is set to Custom.
Public propertyCustomPortName Custom port name can be used when Port is set to Custom. You can use any name, different from COMMxx.
Public propertyDataWidth Number of bits in the bytes transmitted and received.
Protected propertyDesignModeGets a value that indicates whether the Component is currently in design mode.
(Inherited from Component)
Public propertyDetectionMethod Detection method for detecting GSM modem.
Public propertyEnableDtrOnOpen Enable/disable DTR when the port is open.
Public propertyEnableRtsOnOpen Enable/disable RTS when the port is open.
Protected propertyEventsGets the list of event handlers that are attached to this Component.
(Inherited from Component)
Public propertyHardwareFlowControl Hardware flow control of the serial port.
Public propertyIdleInterval Idle time interval in milliseconds. If the elapsed time from the last receive is higher than IdleInterval, Idle event occurs. If IdleInterval is 0, Idle event never occurs.
Public propertyIdleTimeoutInterval You can set a time-out value to automatically close the connection and fire the IdleTimeout event, if there is no data received in several milliseconds. A value of zero indicates that time-out is not used.
Public propertyInputBuffer Recommended size of the device's internal input buffer, in bytes.
Public propertyInterval Time interval between two receiving in milliseconds (frequency).
Public propertyCode exampleIsFaulted Indicates that the last connection was faulted.
Public propertyIsIdle True if Idle occurred, until Resumed.
Public propertyIsListing True, if the stored messages are listing, false, if already done. Use it with GetAllSms method, to be able to determine when all the messages were read.
Public propertyIsReceiving This property is false when the component is receiving data from the port, otherwise is false. Use this property to check if the component is inside a receiving process.
Public propertyIsSending This property is true when the component is sending data to the port, otherwise is false. Use this property to check if the component is inside a sending process.
Public propertyLastTimeReceived Last date-time when data received from the serial port.
Public propertyMaxMemoryPhonebookContactCount Maximum number of contacts in memory phonebook.
Public propertyMaxSimPhonebookContactCount Maximum number of contacts in SIM phone book.
Public propertyMemoryPhonebook Phonebook of the phone's memory.
Public propertyMessageFormat SMS message format. Can be PDU or text.
Public propertyMinCheckDisconnectedInterval The minimum time interval in milliseconds, for which the port availability is checked. For time critical usage it's recommended to set it to a higher value. Default value is 50.
Public propertyNeedSynchronization Set this property to true for thread safety. The default value is false. Note: if you set it to true, you may experiment thread interblocking and lower speed.
Public propertyOutputBuffer Recommended size of the device's internal output buffer, in bytes.
Public propertyParityBits Parity scheme to be used.
Public propertyPin PIN code.
Public propertyPort Physical name of the serial port.
Public propertyPriority Priority of the receiver thread.
Protected propertyReadIntervalTimeout Maximum time allowed to elapse between the arrival of two characters on the communications line, in milliseconds. During a ReadFile operation, the time period begins when the first character is received. If the interval between the arrival of any two characters exceeds this amount, the ReadFile operation is completed and any buffered data is returned. A value of zero indicates that interval time-outs are not used. A value of MAXDWORD, combined with zero values for both the ReadTotalTimeoutConstant and ReadTotalTimeoutMultiplier members, specifies that the read operation is to return immediately with the characters that have already been received, even if no characters have been received.
Protected propertyReadTotalTimeoutConstant Constant used to calculate the total time-out period for read operations, in milliseconds. For each read operation, this value is added to the product of the ReadTotalTimeoutMultiplier member and the requested number of bytes. A value of zero for both the ReadTotalTimeoutMultiplier and ReadTotalTimeoutConstant members indicates that total time-outs are not used for read operations.
Protected propertyReadTotalTimeoutMultiplier Multiplier used to calculate the total time-out period for read operations, in milliseconds. For each read operation, this value is multiplied by the requested number of bytes to be read.
Public propertySimPhonebook Phonebook of the SIM card.
Public propertySiteGets or sets the ISite of the Component.
(Inherited from Component)
Public propertySkipInit Skip initialization commands at open.
Public propertySkipSetupFailed When this property is true, if setting serial parameters like DCB in the Open method fails, will ignore this. Otherwise method Open will return false and the port will not be opened.
Public propertySoftwareFlowControl Software flow control of the serial port.
Public propertyStopBits Number of stop bits to be used.
Public propertyStorageLocation SMS storage location. Can be SIM or phone memory.
Public propertyStatic memberUnlockKey It is used to protect your software after deployment. You will have to set it to the correct value, before opening the port. You will find the key in your software package.
Public propertyWriteTotalTimeoutConstant Constant used to calculate the total time-out period for write operations, in milliseconds. For each write operation, this value is added to the product of the WriteTotalTimeoutMultiplier member and the number of bytes to be written. A value of zero for both the WriteTotalTimeoutMultiplier and WriteTotalTimeoutConstant members indicates that total time-outs are not used for write operations.
Public propertyWriteTotalTimeoutMultiplier Multiplier used to calculate the total time-out period for write operations, in milliseconds. For each write operation, this value is multiplied by the number of bytes to be written.
Top
Methods
 NameDescription
Public methodAddContact Add a contact to the phone book.
Public methodAnswerCall Answer incoming call.
Public methodStatic memberAsciiByteArrayToString Converts ANSI byte array to string.
Public methodStatic memberByteArrayToDecimalString Converts byte array to decimal string representation.
Public methodStatic memberByteArrayToHexaString Converts byte array to hexadecimal string representation.
Public methodClearInputBuffer Clears input buffer
Public methodClearOutputBuffer Clears output buffer
Public methodClose Closes the serial port.
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
(Inherited from MarshalByRefObject)
Public methodDeleteContact Delete a contact from the phone book.
Public methodDeleteSms Delete an SMS message specified by index from the selected location (PhoneSim or PhoneMemory).
Public methodDetectAllGsm Detects all GSM modems connected to the system and returns the communication port and baud rate.
Public methodDetectAllGsm(SerialBaudRate, SerialBaudRate) Detects all GSM modems connected to the system and returns the communication port and baud rate. Only baud rate values between startBaudRate and endBaudRate are checked.
Public methodDetectGsm(SerialCommPort, SerialBaudRate) Detects the first GSM modem connected to the system and returns as output parameters the communication port and baud rate.
Public methodDetectGsm(String, SerialBaudRate) Detects the first GSM modem connected to the system and returns as output parameters the communication port and baud rate.
Public methodDetectGsm(SerialBaudRate, SerialBaudRate, String, SerialBaudRate) Detects the first GSM modem connected to the system and returns as output parameters the communication port and baud rate. Only baud rate values between startBaudRate and endBaudRate are checked.
Public methodDetectGsm(SerialBaudRate, SerialBaudRate, SerialCommPort, SerialBaudRate) Detects the first GSM modem connected to the system and returns as output parameters the communication port and baud rate. Only baud rate values between startBaudRate and endBaudRate are checked.
Public methodDialData Dial phone number in data mode.
Public methodDialVoice Dial phone number in voice mode.
Public methodDisposeReleases all resources used by the Component.
(Inherited from Component)
Protected methodDispose(Boolean) Clean up any resources being used.
(Overrides ComponentDispose(Boolean))
Public methodEnableEcho Enable or disable echo.
Public methodEnterPin Enter PIN code if necessary.
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Public methodExecuteATCommand(String, Char) Execute AT command.
Public methodExecuteATCommand(String, ListString, Int32, Char) Execute AT command.
Protected methodFinalize Finalizer.
(Overrides ComponentFinalize)
Public methodGetAllSms Return all the SMS from location memory (PhoneSim or PhoneMemory), depending on SmsType.
Public methodGetAvailableInputBufferSize Returns the size of the buffer available to be read (bytes to read). You can use this method, before ReadBuffer.
Public methodStatic memberGetExistingCommPortNames Returns the existing serial port names of the system.
Public methodStatic memberGetExistingCommPorts Returns the existing serial ports of the system.
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetImei Return IMEI number of the modem / phone.
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance.
(Inherited from MarshalByRefObject)
Protected methodGetServiceReturns an object that represents a service provided by the Component or by its Container.
(Inherited from Component)
Public methodGetSms Returns the SMS from location memory (PhoneSim or PhoneMemory), indicated by index. If the message exists, ReadMessage event will fire with the text of the message, time stamp, caller and center number.
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Public methodStatic memberGsm7BitDefaultAlphabet Return GSM 7 bit alphabet.
Public methodHideMyPhoneNumber Hide or show phone number, when calling.
Public methodInitGsmModem Initialize the modem.
Public methodInitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance.
(Inherited from MarshalByRefObject)
Public methodStatic memberIntToSerialCommPort Converts string to SerialCommPort.
Public methodIsConnected Returns true if the serial port is connected.
Public methodStatic memberIsExistingCommPort(SerialCommPort) Checks if a serial port exists.
Public methodStatic memberIsExistingCommPort(String) Checks if a serial port exists.
Public methodLoadPhonebook Load the phonebook of the phone.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
Protected methodMemberwiseClone(Boolean)Creates a shallow copy of the current MarshalByRefObject object.
(Inherited from MarshalByRefObject)
Protected methodOnConnected Raises the Connected event.
Protected methodOnContactLoaded Raises the ContactLoaded event.
Protected methodOnDetecting Raises the Detecting event.
Protected methodOnDisconnected Raises the Disconnected event.
Protected methodOnError Raises the Error event.
Protected methodOnFaulted Raises the Faulted event.
Protected methodOnIdle Raises the Idle event.
Protected methodOnIdleTimeout Raises the IdleTimeout event.
Protected methodOnInitialized Raises the Initialized event.
Protected methodOnNewMessage Raises the NewMessage event.
Protected methodOnReadMessage Raises the ReadMessage event.
Protected methodOnReceived Raises the Received event.
Protected methodOnReconnecting Raises the Reconnecting event.
Protected methodOnResumed Raises the Resumed event.
Protected methodOnRing Raises the Ring event.
Protected methodOnSent Raises the Sent event.
Public methodOpen Opens the serial port.
Public methodReadBuffer Synchronously reads the received data from the serial port to a byte array. Otherwise returns null.
Public methodReadStringUpToEndChars Reads the serial port up to the first occurence of one of the endChars sequences of the endCharsList collection.
Public methodResetIdleState Resets the idle state of the port.
Public methodSendAsciiString Send an ASCII string to the serial port.
Public methodSendByteArray Send a byte array to the serial port.
Public methodSendSmsAsPdu Send SMS in PDU format.
Public methodSendSmsAsText Send SMS in text format.
Public methodSerialCommPortToString Converts SerialCommPort to string.
Public methodSetAutoAnswer Set auto answer.
Public methodSetMessageFormat Set the SMS message format.
Public methodSetStorageLocation Set SMS storage location.
Public methodStatic memberStringToAsciiByteArray Converts string to ANSI byte array.
Public methodStatic memberStringToSerialCommPort Converts string to SerialCommPort.
Public methodTerminateCall Hang up current call.
Public methodTestDevice Tests if the connection is alive.
Public methodTestGsmModemCapabilities Tests the capability of the GSM modem.
Public methodToStringReturns a String containing the name of the Component, if any. This method should not be overridden.
(Inherited from Component)
Top
Events
 NameDescription
Public eventConnected Occurs after the serial port is connected.
Public eventContactLoaded Occurs when a contact is loaded from the phone book.
Public eventDetecting Occurs when the GPS receiver detection is in progress and there are new values of port or baud rate in view.
Public eventDisconnected Occurs when the serial port is disconnected.
Public eventDisposedOccurs when the component is disposed by a call to the Dispose method.
(Inherited from Component)
Public eventError Occurs when the GSM modem reports an error in the command execution.
Public eventCode exampleFaulted Occurs when the serial port communication is faulted.
Public eventIdle If the elapsed time from the last receive is higher than IdleInterval (milliseconds), Idle event occurs. If IdleTinerval is 0, this event will never occur.
Public eventIdleTimeout Occurs when there is no data received in several milliseconds, the interval is specified in the IdleTimeoutInterval property.
Public eventInitialized Occurs after the GSM modem was initialized.
Public eventNewMessage Occurs when new SMS message is received.
Public eventReadMessage Occurs when an SMS is requested by GetSms method or when new SMS is received.
Public eventReceived Occurs when data was received.
Public eventReconnecting Occurs when the serial port connection was lost (faulted) and tries to reconnect. AutoReconnect must be true.
Public eventResumed Occurs when the receiver is idle and data is received.
Public eventRing Occurs when the phone is ringing.
Public eventSent Occurs when data was sent.
Top
Fields
 NameDescription
Public fieldStatic memberPhoneMemory Phone memory.
Public fieldStatic memberPhoneSim Phone SIM.
Top
See Also