
Welcome to MfcSMS, a collection of MFC classes to
send SMS messages via your mobile phone / cellphone.
For the code to operate, you will need to have a phone
attached to a serial port on the PC (or the software which comes with the phone
must create a virtual serial port if connected via USB, Bluetooth, IrDA etc) and
the phone must support the extended Hayes commands used to send an SMS message. Specifically the code uses the following
commands: "AT", "AT+CSMS", "AT+CMGF" and "AT+CMGS".
The classes internally converts any string data
presented to it to the GSM 7 bit or UCS2 alphabets. For further information about SMS,
have a look at http://www.dreamfabric.com/sms/
from which the code is based.
Features
- Simple and clean C++
interface.
- All the code is UNICODE
compliant and build configurations are provided for this.
- Will work with almost all
mobile phones which support being connected to a PC.
- Will work with extended characters as well
as the usual upper and lowercase Latin letters and numbers.
- Supports sending Unicode SMS Messages.
The enclosed
zip file contains the source code and a
simple test program to exercise all of the classes.
Copyright
- You are allowed to include the source code in
any product (commercial, shareware, freeware or otherwise) when your product
is released in binary form.
- You are allowed to modify the source code in
any way you want except you cannot modify the copyright details at the top
of each module.
- If you want to distribute source code with
your application, then you are only allowed to distribute versions released
by the author. This is to maintain a single distribution point for the
source code.
Updates
V1.0 (31 October 2002)
V1.01 (8 November 2002)
- Now uses "\r" consistently as terminator when sending AT commands to the mobile.
- The exception class nows use HRESULT based error values instead of SDK style GetLastError error codes. This allows user defined error codes to be more easily defined.
V1.02 (12 March 2005)
- Addition of a CSMSSerialPort::GetLastResponse method. This last response is now also included in CSMSExceptions when necessary. Thanks to Serhiy Pavlov for suggesting this addition.
- Write timeouts are now also applied in Set0ReadTimeout which is called by CSMSSerialPort::Open.
V1.03 (26 March 2005)
- Now calls SetDCB upon opening the port to ensure it is put in a valid state and baud rate. This helps fix problems
with some mobile phone models. Thanks to Serhiy Pavlov for reporting this problem.
- Open method now allows an explicit baud rate to be specified.
- General tidy up of the exception throwing code
V1.04 (9 July 2006)
- Updated copyright details.
- Code now uses newer C++ style casts instead of C style casts.
- Optimized CSMSMessage constructor code
- Replaced calls to ZeroMemory with memset
- Optimized CSMSSerialPort constructor code
- CSMSSerialPort is no longer derived from CObject as it was not really
required
- Code now uses SEVERITY_ERROR define for MAKE_HRESULT calls.
- Renamed AfxThrowSMSException to ThrowSMSException and made it part of
the CSMSSerialPort class.
- Updated the code to clean compile on VC 2005
- Removed EnumSerialPorts module from download
- Updated sample app to warn user when it cannot find any serial ports on
start-up
V1.05 (3 August 2008)
- Updated copyright details.
- Removed VC 6 style classwizard comments from the sample app.
- Updated the sample app to clean compile on VC 2008
- Sample app now uses CEnumerateSerial::UsingSetupAPI1 to enumerate serial
ports
- Sample app now displays the friendly name of the port also
- Updated code to compile correctly using _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
define
- Reworked the exception class to be in line with the other exception
classes of the author.
- Code now compiles cleanly using Code Analysis (/analyze)
- The code now only supports VC 2005 or later.
- Internally the code now opens the serial port in overlapped mode
- Removed the Attach and Detach methods.
- Increased the default timeout to 15 seconds.
- Added support for the sending using the UCS2 alphabet. Thanks to Andrew
Komiagin for this very nice addition.