How can we help?

AxSms.Android


Introduction

Skip to properties and methods

The Android object connects to the Auron SMS Agent for Android app to send and receive SMS messages. The Android SMS agent app uses the Android native SMS API. This way it will automatically know when to use Unicode for instance. But it will not support all of the SMS functionality that e.g. a GSM modem supports.

For sending the Android object uses these Message properties:

  • ToAddres
  • Body

When receiving the Android objects sets these Message properties:

  • FromAddress
  • ReceiveTime
  • GsmSmscAddress
  • Body

To use the Android object you will need to have the Auron SMS Agent for Android installed on your smartphone. Your smartphone should be connected through WIFI to the same network as your Android object instance.

Send SMS using your Android smartphone

This sample will send out a single SMS message though your Android phone.

Set objAndroid = CreateObject("AxSms.Android")
Set objMessage = CreateObject("AxSms.Message")

' Show version information
Wscript.Echo "Auron SMS Component " & objAndroid.Version
Wscript.Echo "Build: " & objAndroid.Build & vbCrLf & "Module: " & objAndroid.Module
Wscript.Echo "License Status: " & objAndroid.LicenseStatus

objAndroid.LogFile = "test.log"

' Connect to IP address shown in SMS agent app
objAndroid.Connect "192.168.1.6", 7770
If objAndroid.LastError <> 0 Then
  WScript.Echo "Error: " & objAndroid.GetErrorDescription(objAndroid.LastError)
  WScript.Quit 1
End If

' Compose an SMS message
objMessage.ToAddress = "+3611223344"
objMessage.Body = "Hello from my PC!" 

objAndroid.SendSms(objMessage)
If objAndroid.LastError <> 0 Then
  WScript.Echo "Error: " & objAndroid.GetErrorDescription(objAndroid.LastError)
  WScript.Quit 1
End If

objAndroid.Disconnect
WScript.Echo "Done!"

Receive SMS using your Android smartphone

This sample connects to your Android smartphone and waits for incoming SMS messages

Set objAndroid = CreateObject("AxSms.Android")
Set objMessage = CreateObject("AxSms.Message")

' Show version information
Wscript.Echo "Auron SMS Component " & objAndroid.Version
Wscript.Echo "Build: " & objAndroid.Build & vbCrLf & "Module: " & objAndroid.Module
Wscript.Echo "License Status: " & objAndroid.LicenseStatus

objAndroid.LogFile = "test.log"

' Connect to IP address shown in SMS agent app
objAndroid.Connect "192.168.1.6", 7770
If objAndroid.LastError <> 0 Then
  WScript.Echo "Error: " & objAndroid.GetErrorDescription(objAndroid.LastError)
  WScript.Quit 1
End If

' Wait for incoming SMS messages while we're connected
While objAndroid.IsConnected
  Set objSms = objAndroid.ReceiveSms 
  If objAndroid.LastError = 0 Then    
    WScript.Echo "Received SMS from: " & objSms.FromAddress
    WScript.Echo "Body: " & objSms.Body  
  End If
  objAndroid.Sleep 10
WEnd

objAndroid.Disconnect
WScript.Echo "Done!"

Properties and Methods

Property Type Read/Write Description
Version String Read Version number of the SMS Component
Build String Read Build number of the SMS Component
Module String Read Module name of the SMS Component
LicenseStatus String Read License Status
LicenseKey String Read/Write License Key
LastError Number Read Result of the last called method
LogFile String Read/Write The path to a logfile which can be used for troubleshooting
AppVersion String Read The version of the Auron SMS Agent app
DeviceInfo String Read The device model and Android version
IsConnected Boolean Read Returns true while the Android object is connected
ConnectTimeoutMs Integer Read/Write Timeout in ms before the connection fails
CommandTimeoutMs Integer Read/Write Timeout in ms before a command fails.
SendSmsTimeoutMs Integer Read/Write Timeout in ms before sending an SMS fails.

Method Description
Clear Reset all properties to their default values
SaveLicenseKey Save the License Key in the registry
GetErrorDescription Get the description of the given error
Sleep Sleep for the specified number of milliseconds
Connect Connect to your Android device
Disconnect Disconnect from your Android device
SendSms Send an SMS
ReceiveSms Receive SMS

Version property

Return the version number of the SMS Component

Example:

Set objAndroid = CreateObject("AxSms.Android")
WScript.Echo "SMS Component Version " & objAndroid.Version & "; Build " & _
  objAndroid.Build & "; Module " & objAndroid.Module
WScript.Echo "License Status: " & objAndroid.LicenseStatus & vbCrLf
...

Build property

Return the build number of the SMS Component.

Example:

Set objAndroid = CreateObject("AxSms.Android")
WScript.Echo "SMS Component Version " & objAndroid.Version & "; Build " & _
objAndroid.Build & "; Module " & objAndroid.Module
WScript.Echo "License Status: " & objAndroid.LicenseStatus & vbCrLf
...

Module property

Return the module name of the SMS Component.

Example:

Set objAndroid = CreateObject("AxSms.Android")
WScript.Echo "SMS Component Version " & objAndroid.Version & "; Build " & _
objAndroid.Build & "; Module " & objAndroid.Module
WScript.Echo "License Status: " & objAndroid.LicenseStatus & vbCrLf
...

LicenseStatus property

The status of your license. In case you have not licensed the product, the property holds the trial expiration date. For details, see Product Activation.

Example:

Set objAndroid = CreateObject("AxSms.Android")                 ' Create new instance
WScript.Echo "License Status: " & objAndroid.LicenseStatus
WScript.Echo "License Key: " & objAndroid.LicenseKey

LicenseKey property

A license key is required to unlock this component after the trial period has expired. Assign the LicenseKey property every time a new instance of this component is created (see code below). Alternatively, the LicenseKey property can be set automatically. This requires the license key to be stored in the registry. For details, see Product Activation.

Example:

Set objAndroid = CreateObject("AxSms.Android")                 ' Create new instance
objAndroid.LicenseKey = "XXXXX-XXXXX-XXXXX"                ' Assign your license key 
WScript.Echo "LicenseKey: " & objAndroid.LicenseKey

LastError property

Completion code of the last called method. To find the error description of a given error code, go to the online error codes codes page.

Example:

Set objAndroid = CreateObject("AxSms.Android")  
...  
Set objMessage = CreateObject("AxSms.Message")
objMessage.ToAddress = "+31611223344"
objMessage.Body = "Short text message"
objAndroid.SendSms objMessage
WScript.Echo "SendSms result:" &  objAndroid.LastError ' Is message sent ?  
...

LogFile property

By default, LogFile holds an empty string and nothing is logged. If a valid file name is assigned to it, the SMS Component will write debug information to this file. Output data is written at the end of the file, the file is not cleared.

Example:

Set objAndroid = CreateObject("AxSms.Android")   
objAndroid.LogFile = "C:\temp\log.txt"
...
Set objMessage = CreateObject("AxSms.Message")
objMessage.ToAddress = "+31611223344"
objMessage.Body = "Short text message"  
objAndroid.SendSms objMessage
...

AppVersion property

After connecting to your Android phone this property returns the version of the Android SMS Agent app you are running.

Example:

Set objAndroid = CreateObject("AxSms.Android")
...
objAndroid.Connect "192.168.1.6", 7770
If objAndroid.LastError <> 0 Then
  WScript.Echo "Error: " & objAndroid.GetErrorDescription(objAndroid.LastError)
  WScript.Quit 1
End If

WScript.Echo "Version: " & objAndroid.AppVersion
WScript.Echo "Device Info: " & objAndroid.DeviceInfo
...

DeviceInfo property

After connecting to your Android phone this property returns the phone model and Android version.

Example:

Set objAndroid = CreateObject("AxSms.Android")
...
objAndroid.Connect "192.168.1.6", 7770
If objAndroid.LastError <> 0 Then
  WScript.Echo "Error: " & objAndroid.GetErrorDescription(objAndroid.LastError)
  WScript.Quit 1
End If

WScript.Echo "Version: " & objAndroid.AppVersion
WScript.Echo "Device Info: " & objAndroid.DeviceInfo
...

IsConnected property

After connecting to your Android phone this property returns true while the connection is valid.

Example:

Set objAndroid = CreateObject("AxSms.Android")
...
objAndroid.Connect "192.168.1.6", 7770
If objAndroid.LastError <> 0 Then
  WScript.Echo "Error: " & objAndroid.GetErrorDescription(objAndroid.LastError)
  WScript.Quit 1
End If

While objAndroid.IsConnected
  Set objSms = objAndroid.ReceiveSms 
  If objAndroid.LastError = 0 Then    
    WScript.Echo "Received SMS from: " & objSms.FromAddress
    WScript.Echo "Body: " & objSms.Body  
  End If
  objAndroid.Sleep 10
WEnd
...

ConnectTimeoutMs property

This timeout is only used when connecting to the Android phone.

The default value is 5000.

Example:

Set objAndroid = CreateObject("AxSms.Android")
...
objAndroid.CommandTimeoutMs = 10000
objAndroid.ConnectTimeoutMs = 10000
objAndroid.SendSmsTimeoutMs = 20000

objAndroid.Connect "192.168.1.6", 7770
If objAndroid.LastError <> 0 Then
  WScript.Echo "Error: " & objAndroid.GetErrorDescription(objAndroid.LastError)
  WScript.Quit 1
End If
...

CommandTimeoutMs property

This timeout is used for sending general commands to the Android phone.

The default value is 5000.

Example:

Set objAndroid = CreateObject("AxSms.Android")
...
objAndroid.CommandTimeoutMs = 10000
objAndroid.ConnectTimeoutMs = 10000
objAndroid.SendSmsTimeoutMs = 20000

objAndroid.Connect "192.168.1.6", 7770
If objAndroid.LastError <> 0 Then
  WScript.Echo "Error: " & objAndroid.GetErrorDescription(objAndroid.LastError)
  WScript.Quit 1
End If
...

SendSmsTimeoutMs property

This timeout is used when sending an SMS message through the Android phone. If the process of sending an SMS takes longer than this amount of milliseconds it will fail automatically.

The default value is 10000.

Example:

Set objAndroid = CreateObject("AxSms.Android")
...
objAndroid.SendSmsTimeoutMs = 20000

objAndroid.Connect "192.168.1.6", 7770
If objAndroid.LastError <> 0 Then
  WScript.Echo "Error: " & objAndroid.GetErrorDescription(objAndroid.LastError)
  WScript.Quit 1
End If

objAndroid.SendSms(objMessage)
If objAndroid.LastError <> 0 Then
  WScript.Echo "Error: " & objAndroid.GetErrorDescription(objAndroid.LastError)
  WScript.Quit 1
End If
...

Clear method

This method resets all properties to their default values.

Parameters:

  • None

Return value:

Always 0.

Example:

Set objAndroid = CreateObject("AxSms.Android")
....
objAndroid.Clear
...

SaveLicenseKey method

Description:

Use SaveLicenseKey to store the license key permanently in the registry. When a license key is saved, it is restored automatically every time a new instance of the object (‘Gsm’) is created. It is not recommended to save the license key if you distribute the component with your own software, because the key can be easily used by others.

Parameters:

  • None.

Return value:

Always 0. Check LastError property to see if the method was completed successfully.

Example:

Set objAndroid = CreateObject("AxSms.Android")                 ' Create new instance
objAndroid.LicenseKey = "XXXXX-XXXXX-XXXXX"
objAndroid.SaveLicenseKey                                     ' Save license key to registry

For more information, see Product Activation.

GetErrorDescription method

GetErrorDescription provides the error description of a given error code.

Parameters:

  • The error code

Return value:

The error string.

Example:

Set objAndroid = CreateObject("AxSms.Android")   
objAndroid.LogFile = "C:\temp\log.txt"
...
Set objMessage = CreateObject("AxSms.Message")
objMessage.ToAddress = "+31611223344"
objMessage.Body = "Short text message"  
objAndroid.SendSms objMessage
WScript.Echo "SendSms result: " & objAndroid.LastError & ", " & _
  objAndroid.GetErrorDescription(objAndroid.LastError)

Sleep method

This method suspends the current thread for the specified number of milliseconds.

Parameters:

  • Milliseconds to sleep

Return value:

Always 0.

Example:

Set objAndroid = CreateObject("AxSms.Android")
....
objAndroid.Sleep 1000
...

Connect method

This method connected to the specified Android phone. Make sure that the Auron SMS Agent for Android is installed.

Use the IsConnected property to find the connection is still valid.

Parameters:

  • IP address
  • Port (Default: 7770)

Return value:

None

Example:

Set objAndroid = CreateObject("AxSms.Android")
...
' Connect to IP address shown in SMS agent app
objAndroid.Connect "192.168.1.6", 7770
If objAndroid.LastError <> 0 Then
  WScript.Echo "Error: " & objAndroid.GetErrorDescription(objAndroid.LastError)
  WScript.Quit 1
End If
...
objAndroid.Disconnect

Disconnect method

This method disconnects from your Android device.

Parameters:

  • None

Return value:

None

Example:

Set objAndroid = CreateObject("AxSms.Android")
...
' Connect to IP address shown in SMS agent app
objAndroid.Connect "192.168.1.6", 7770
If objAndroid.LastError <> 0 Then
  WScript.Echo "Error: " & objAndroid.GetErrorDescription(objAndroid.LastError)
  WScript.Quit 1
End If
...
objAndroid.Disconnect

SendSms method

Sends an SMS through the connected Android device. This method will wait until the SMS is sent or the SendSmsTimeoutMs is reached.

Parameters:

  • None

Return value:

None

Example:

Set objAndroid = CreateObject("AxSms.Android")
...
' Compose an SMS message
objMessage.ToAddress = "+31611223344"
objMessage.Body = "Hello from my PC!" 

objAndroid.SendSms(objMessage)
If objAndroid.LastError <> 0 Then
  WScript.Echo "Error: " & objAndroid.GetErrorDescription(objAndroid.LastError)
  WScript.Quit 1
End If

ReceiveSms method

This method checks if there are any SMS messages ready to be received. If no messages are ready to be received at this time the LastError property will be set to a non-zero value.

Parameters:

  • None

Return value:

Message object or Nothing if LastError property is non zero.

Example:

Set objAndroid = CreateObject("AxSms.Android")
...
' Wait for incoming SMS messages while we're connected
While objAndroid.IsConnected
  Set objSms = objAndroid.ReceiveSms 
  If objAndroid.LastError = 0 Then    
    WScript.Echo "Received SMS from: " & objSms.FromAddress
    WScript.Echo "Body: " & objSms.Body  
  End If
  objAndroid.Sleep 10
WEnd

The Android object connects to the Auron SMS Agent for Android app to send and receive SMS messages. The Android SMS agent app uses the Android native SMS API. This way it will automatically know when to use Unicode for instance. But it will not support all of the SMS functionality that e.g. a GSM modem supports.

For sending the Android object uses these Message properties:

  • ToAddres
  • Body

When receiving the Android objects sets these Message properties:

  • FromAddress
  • ReceiveTime
  • GsmSmscAddress
  • Body

To use the Android object you will need to have the Auron SMS Agent for Android installed on your smartphone. Your smartphone should be connected through WIFI to the same network as your Android object instance.

Send SMS using your Android smartphone

This sample will send out a single SMS message though your Android phone.

Set objAndroid = CreateObject("AxSms.Android")
Set objMessage = CreateObject("AxSms.Message")

' Show version information
Wscript.Echo "Auron SMS Component " & objAndroid.Version
Wscript.Echo "Build: " & objAndroid.Build & vbCrLf & "Module: " & objAndroid.Module
Wscript.Echo "License Status: " & objAndroid.LicenseStatus

objAndroid.LogFile = "test.log"

' Connect to IP address shown in SMS agent app
objAndroid.Connect "192.168.1.6", 7770
If objAndroid.LastError <> 0 Then
  WScript.Echo "Error: " & objAndroid.GetErrorDescription(objAndroid.LastError)
  WScript.Quit 1
End If

' Compose an SMS message
objMessage.ToAddress = "+3611223344"
objMessage.Body = "Hello from my PC!" 

objAndroid.SendSms(objMessage)
If objAndroid.LastError <> 0 Then
  WScript.Echo "Error: " & objAndroid.GetErrorDescription(objAndroid.LastError)
  WScript.Quit 1
End If

objAndroid.Disconnect
WScript.Echo "Done!"

Receive SMS using your Android smartphone

This sample connects to your Android smartphone and waits for incoming SMS messages

Set objAndroid = CreateObject("AxSms.Android")
Set objMessage = CreateObject("AxSms.Message")

' Show version information
Wscript.Echo "Auron SMS Component " & objAndroid.Version
Wscript.Echo "Build: " & objAndroid.Build & vbCrLf & "Module: " & objAndroid.Module
Wscript.Echo "License Status: " & objAndroid.LicenseStatus

objAndroid.LogFile = "test.log"

' Connect to IP address shown in SMS agent app
objAndroid.Connect "192.168.1.6", 7770
If objAndroid.LastError <> 0 Then
  WScript.Echo "Error: " & objAndroid.GetErrorDescription(objAndroid.LastError)
  WScript.Quit 1
End If

' Wait for incoming SMS messages while we're connected
While objAndroid.IsConnected
  Set objSms = objAndroid.ReceiveSms 
  If objAndroid.LastError = 0 Then    
    WScript.Echo "Received SMS from: " & objSms.FromAddress
    WScript.Echo "Body: " & objSms.Body  
  End If
  objAndroid.Sleep 10
WEnd

objAndroid.Disconnect
WScript.Echo "Done!"