Gary Baker is a C and assembler programmer with a vast amount of experience on a myriad of Windows and embedded systems. If you have any bespoke projects or contracts you wish to discuss please email g_b001@yahoo.co.uk

Windows C Programming projects

SMS: Turn your pc into a text messaging server using an old phone

Getting started

Why do this?

Well, we'll be able to text our PC and have it run a program, report back on something, activate something else, beep and frighten the cat or make us feel right at home and ignore us. Your limit is your imagination. When we've done this first simple text type interface we shall look at how to send back - or on to someone else - multimedia stuff, pictures, music etc.
It'll handle a text message every couple of seconds or so - that's thousands a day! Sounds expensive. Unless you can make money out of it - which loads of companies do - but they use bulk SMS providers. Even so, this is a great way to test an SMS idea.

Hardware
I use an old Nokia 7110 with a serial cable and an old laptop running windows. Yes, this one's done via serial comms. Easy peasy.

Software
Well, we're about to write that so I'm going to astound you with psuedo code, a much underrated design tool. Each instance of the program may spawn another instance of itself with instructions to look at a different comms port. In this way we can daisy-chain instances of the program together to deal with a multitude of mobile phones from one pc. (Cool)

The program, smsterm.exe will be initiated either on it's own:
smsterm.exe
or with 1 (one) parameter
smsterm.exe ini=filename.txt
The ini=filename.txt will hold the initialisation data: which serial port, speed etc

Some pseudo code outlining our program:

// ****************************************************************************************
smsterm.exe:
		Check the command line parameters
		If 'ini=' Load the file otherwise set the defauts
		Start the sockets interface
		Create a window for text output (Viz Window) so we can see what's happening
		Create a log file mutex
		Clean out any 'pending' text messages we saved from a previous run
	OpenCommsLabel:
		Open the comms port
		if successful
		{
			LOOP-ForEVER
			{
				Say 'Hello' to the modem
				If it fails to respond: Log it, beep pathetically, retry
				if it's okay
				{
					If there's a message: log it, process it, delete it
					If we have pending text messages: send them
				}
				Sleep for a while
				User wants us to exit?
				if yes: goto finished label
			} // end Loop-forever
		}
		if failed to open comms port
		{
			Log that we failed
			Tell user and quit or try again
		}
	FinishedLabel:
		Log that we're done
		Close the Viz Window
		Clean up the sockets
		Kill the mutex
		Exit
// ****************************************************************************************		
	

   




  • Copyright (c) Gary Baker 2009 some rights reserved.
  • If you redistribute Gary Baker's content, please follow these conditions:
    • You must attribute the work to Gary Baker by prominently linking back to the source pages on Brambling Books. An ideal example would be: Article or tutorial provided by Gary Baker, BramblingBooks.co.uk/Software/
    • You must not use the content for commercial purposes. However, commercial republishing requests are often granted if you email info@bramblingbooks.co.uk and ask.
    • If you alter, remix, transform, or build upon work found on Brambling Books, you may distribute the resulting work only under the same or similar conditions.