Welcome to MfcSMS, a collection of C++ classes to send SMS messages via
your mobile phone/cellphone & 3G/4G dongle.
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
AT commands used to send an SMS message. Specifically the code uses the following
commands: "AT+CSMS", "AT+CMGF" and "AT+CMGS". The
precise specification of the PDUs is given in
3GPP TS 23.040.
The spec for the AT commands is in
3GPP TS 27.005.
The GSM-7 character set is described in
3GPP TS 23.038.
Please note that iPhone and Android devices these days do not expose their internal
modem for SMS sending. You are best advised to seek out a 3G dongle such as the
Huawei E220 for use with
MfcSMS.
Features
- Simple and clean C++ interface.
- All the code is UNICODE compliant and build configurations are provided
for this.
- Supports the GSM 7 bit, UCS-2/UTF-16 and 8bit binary alphabets.
- Supports sending concatenated SMS messages via auto inclusion of User Data
Headers (UDH's)
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.15 (2 May 2022)
- Updated copyright details.
- Updated the code to use C++ uniform initialization for all variable
declarations.
v1.14 (9 May 2020)
- Fixed more Clang-Tidy static code analysis warnings in the code.
v1.13 (29 March 2020)
- Updated copyright details.
- Fixed more Clang-Tidy static code analysis warnings in the code.
v1.12 (24 December 2019)
- Fixed various Clang-Tidy static code analysis warnings in the code.
- Replaced BOOL with bool throughout the code.
v1.11 (21 September 2019)
- Replaced enum with enum class throughout the code
- Updated copyright details
v1.10 (21 October 2018)
- Updated copyright details.
- Fixed a number of C++ core guidelines compiler warnings. These changes
mean that the code will now only compile on VC 2017 or later.
- Removed all code which supported CMFCSMS_MFC_EXTENSIONS code
path
v1.09 (19 November 2017)
- Updated the code to compile cleanly when _ATL_NO_AUTOMATIC_NAMESPACE is
defined.
v1.08 (24 September 2017)
- Replaced NULL throughout the codebase with nullptr. This means that the
minimum requirement for the framework is now VC 2010.
- Replaced CString::operator LPC*STR() calls throughout the codebase with
CString::GetString calls
v1.07 (20 May 2017)
- Updated copyright details.
- Updated the code to compile cleanly using /permissive-.
v1.06 (10 July 2016)
- Updated copyright details.
- Updated the project settings to more modern defaults.
- Added SAL annotations to all the code
- Updated the documentation to reference the specs which MfcSMS uses.
- Reworked the classes to optionally compile without MFC. By default the classes
now use STL classes and idioms but if you define CMFCSMS_MFC_EXTENSIONS the
classes will revert back to the MFC behaviour.
- The serial port is now left in the default OS initialized state on opening.
In the process the baud rate parameter to CSMSSerialPort::Open & CSMSSerialPort::InitializePort
has now been removed.
- Reimplemented the 7bit GSM encoding into easier to understand helper methods
- Implemented a rescan button in the sample app
- Reworked the WaitForSerialResponse method to time out correctly on bad responses
- Removed the restriction on sending a 0 length message. In the process the
E_SMS_NO_MESSAGE_TO_PDU_ENCODE error code has been removed.
- Updated the sample app to support an automatic mode to auto detect the Service
Center Number address type and the Phone Number address type.
- Added support for sending the message as raw 8bit encoding.
- Added support for sending concatenated SMS messages using User Data Headers
(UDH's).
- Updated the sample app to display detailed statistics about the text message
which will be sent as the user types the message. This new functionality is
available via the new CSMSMessage::Statistics method.
- Updated the code to clean compile on VC 2008 - VC 2015
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 sending using the UCS2 alphabet. Thanks to Andrew Komiagin
for this very nice addition.
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.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.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.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.0 (31 October 2002)