03.01.2013 Views

Chapter 1

Chapter 1

Chapter 1

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Once connected, the sockets interface makes sending the packet straightforward and we<br />

can simply call RSocket::Write().<br />

void CGdpBTSender::TWriteState::EnterL()<br />

{<br />

// Initiate a write...<br />

iSender.iWriteSocket.Write(iSender.iPacket, iSender.iStatus);<br />

// and wait...<br />

iSender.SetActive();<br />

}<br />

If the write is successful, we can let the handler know. We have also finished the send<br />

operation, have no further states to go onto, and can return NULL.<br />

CGdpStateMachine::TState* CGdpBTSender::TWriteState::CompleteL()<br />

{<br />

// Hey! We're done! Stop going through the state machine<br />

iSender.iHandler->SendComplete(KErrNone);<br />

return NULL;<br />

}<br />

Receiver<br />

Receiving a GDP packet over Bluetooth differs very little from how you would receive data<br />

from any other socket. We must listen for a connection, accept the connection, and then<br />

read our data from the socket.<br />

Figure 20.11 shows, two sequential operations are required to receive GDP packets via<br />

Bluetooth:<br />

Figure 20.11<br />

� Accept: the incoming connection from sender.<br />

� Read: read the packet from the connected device and while we have an active<br />

connection we can wait for additional packets.<br />

Before a connection can be accepted, we must give some consideration to device security.<br />

From the earliest Bluetooth specification, device security has always featured heavily.<br />

Typically connections cannot be made between devices without the consent of the user. For<br />

this reason, we will need to create a session with the Bluetooth security manager (RBtMan)<br />

to modify security settings for incoming GDP connections, to remove the requirement for

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

Saved successfully!

Ooh no, something went wrong!