03.01.2013 Views

Chapter 1

Chapter 1

Chapter 1

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Return to wait state for next message.<br />

return static_cast (&iReceiver.iWaitState);<br />

}<br />

We remove the GDP SMS pattern from the message and convert the data into narrow<br />

format before passing the data to the handler. Finally, we set the next state to TWaitState<br />

to receive further GDP SMS messages.<br />

As with CGdpSmsSender, if we discover an error, we attempt to reset the state machine and<br />

wait for the message to arrive again.<br />

Resource manager<br />

So far, I've just been using the resource manager without actually explaining what it is.<br />

Basically, it's a convenient place to hold onto any resources that are shared between the<br />

sender and the receiver. Specifically, these are connections to the socket server and the file<br />

server. It also implements a bit of functionality in the form of OpenL(), Close() and<br />

ResetL()functions to set up and maintain these resources. Keeping this stuff out of the<br />

central CGdpSmsComms class keeps the fa¸cade interface clean from any implementation<br />

detail, minimizing the dependency of the GDP client on the implementation's internals.<br />

CGdpSmsResourceManager is a simple class, as it does not have any of the active<br />

management functionality and does not carry out any asynchronous task by itself, but simply<br />

acts as a single point of contact (or proxy) for resource access.<br />

class CGdpSmsResourceManager : public CBase<br />

//--------------------------<br />

{<br />

public:<br />

~CGdpSmsResourceManager();<br />

void OpenL();<br />

void Close();<br />

public:<br />

RSocketServ iSocketServer;<br />

RFs iFs;<br />

};<br />

As you can see, the resource manager is not CActive derived – it just holds the shared<br />

resources used by both the sender and the receiver.<br />

20.3 Bluetooth Implementation<br />

Bluetooth is a short-range wireless communications technology, standardized by the<br />

Bluetooth Special Interest Group (SIG) in 1998. With an operating range of approximately 10<br />

m, it is an ideal technology for sharing information between devices. It also does not suffer<br />

the shortcomings of infrared, which requires direct line of sight.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!