diff -r 4816d766a08a -r f345bda72bc4 Symbian3/PDK/Source/GUID-A24D2CEF-88C9-5C63-A14D-85EFFBEF3C92.dita --- a/Symbian3/PDK/Source/GUID-A24D2CEF-88C9-5C63-A14D-85EFFBEF3C92.dita Tue Mar 30 11:42:04 2010 +0100 +++ b/Symbian3/PDK/Source/GUID-A24D2CEF-88C9-5C63-A14D-85EFFBEF3C92.dita Tue Mar 30 11:56:28 2010 +0100 @@ -1,34 +1,70 @@ - - - - - -Connecting and Transferring Data to a Remote Device

Once the device and service have been established, you can connect to the remote service and start using it.

How to Communicate with a Remote Device

Connect to the device through the Connect() function of the generic Symbian OS socket interface RSocket. Bluetooth sockets can be opened using the L2CAP and RFCOMM protocols. For an L2CAP Bluetooth socket, the "port" is the Protocol/Service Multiplexer (PSM) to which to connect; for an RFCOMM the port is the server channel. Where these values are not known, they can be read from the service attribute ProtocolDescriptorList. See Using Bluetooth Service Discovery Agent for details.

You can read and write data using the socket in whatever format the target service expects (AT commands, text, HTTP, PPP etc).

Example

-// Assume have a TInquirySockAddr object, addr, with relevant device info - -// Connect an L2CAP socket -RSocket socket; -// although CBluetoothSocket may be a better option. -RSocketServ socketServ; -TRequestStatus status; -User::LeaveIfError(socket.Open(socketServ,KBTAddrFamily,KSockSeqPacket,KL2CAP)); -User::LeaveIfError(socket.Connect(addr,status)); -User::WaitForRequest(status); - -if (status == KErrNone) - { - // Write some simple data - _LIT8(KDataToWrite,"01234"); - socket.Write(KDataToWrite,status); - User::WaitForRequest(status); - } - -// Close socket -socket.Close(); -

Notes

  • For both the RFCOMM and L2CAP protocols, no data can be sent or received in the Connect() and Shutdown() calls. The versions of these calls that take extra data panic.

  • RFCOMM uses sockets of the stream socket (KSockStream) type.

  • L2CAP uses sockets of the sequenced packet (KSockSeqPacket) type.

Where Next?

This tutorial set takes you through all the steps involved in setting up and communicating over a Bluetooth connection.

  • Selecting a Remote Device

  • Inquiring About Remote Devices

  • Inquiring About Services on a Remote Device

  • Connecting and Transferring Data to a Remote Device - This document

  • Using security on outgoing sockets

\ No newline at end of file + + + + + +Connecting +and Transferring Data to a Remote DeviceOnce the device and service have been established, you can connect +to the remote service and start using it. +
How to Communicate with a Remote Device

Connect +to the device through the Connect() function of the generic +Symbian platform socket interface RSocket. +Bluetooth sockets can be opened using the L2CAP and RFCOMM protocols. For +an L2CAP Bluetooth socket, the "port" is the Protocol/Service Multiplexer +(PSM) to which to connect; for an RFCOMM the port is the server channel. Where +these values are not known, they can be read from the service attribute ProtocolDescriptorList. +See Using Bluetooth +Service Discovery Agent for details.

You can read and write +data using the socket in whatever format the target service expects (AT commands, +text, HTTP, PPP etc).

Example

+// Assume have a TInquirySockAddr object, addr, with relevant device info + +// Connect an L2CAP socket +RSocket socket; +// although CBluetoothSocket may be a better option. +RSocketServ socketServ; +TRequestStatus status; +User::LeaveIfError(socket.Open(socketServ,KBTAddrFamily,KSockSeqPacket,KL2CAP)); +User::LeaveIfError(socket.Connect(addr,status)); +User::WaitForRequest(status); + +if (status == KErrNone) + { + // Write some simple data + _LIT8(KDataToWrite,"01234"); + socket.Write(KDataToWrite,status); + User::WaitForRequest(status); + } + +// Close socket +socket.Close(); +

Notes

    +
  • For both the RFCOMM +and L2CAP protocols, no data can be sent or received in the Connect() and Shutdown() calls. The versions of these calls that +take extra data panic.

  • +
  • RFCOMM uses sockets +of the stream socket (KSockStream) type.

  • +
  • L2CAP uses sockets of +the sequenced packet (KSockSeqPacket) +type.

  • +
+
Where Next?

This tutorial set takes you through +all the steps involved in setting up and communicating over a Bluetooth connection.

    +
  • Selecting +a Remote Device

  • +
  • Inquiring +About Remote Devices

  • +
  • Inquiring +About Services on a Remote Device

  • +
  • Connecting and Transferring +Data to a Remote Device - This document

  • +
  • Using +security on outgoing sockets

  • +
+
\ No newline at end of file