Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 08:33, 9 April 2008.

BTCOMM serial communication.

From Forum Nokia Wiki

Bluetooth CSY is provided primarily to support serial communication (RS232) over Bluetooth. BTComm is itself provided by a serial communications module in the form of a CSY file.

BTComm provides the framework to produce an RS232 emulation plug-in communicating over a Bluetooth RFComm connection.

The following Serial Communication C32 classes are used in making an RS232 BTComm connection:

  • RCommServ - A session on the Serial Comms server.
  • RComm - A subsession on the Serial Comms server.
  • RCommServ::Connect() - Creates a session on the comms server.
  • RCommServ::LoadCommModule() - The desired serial communication protocol Module(CSY Module) is loaded using this function.
  • RComm::Open() - Open a port on the serial server.
  • RComm::Close() - Closes the port.
  • RComm::Read(), RComm::ReadOneOrMore() - Reading data over the port.
  • RComm::Write() - Writing data over the port.

How to use the above APIs for BTCOMM

First you need to create some objects.

// Opening a simple BTCOMM connection.
// Create an RCommServ object.
RCommServ server;
// Create an RComm object.
RComm commport;
// Required LITs
_LIT(KTxtBTCOMM,"BTCOMM");
_LIT(KTxtBTCommName,"BTCOMM::");

Connect to the serial comms server:

server.Connect();

Load the Bluetooth BTComm CSY module using RCommServ::LoadCommModule().

server.LoadCommModule(KTxtBTCOMM);

Prepare the port name for the connection.

TBuf8<15> commname(KTxtBTCommName); commname.AppendNum(0); The TDes8::AppendNum() function above appends the decimal character '0', representing the port for this example, onto the end of the 'commname' descriptor. The RCommServ::GetPortInfo() function is used to discover the port number if it is not known.

Open and configure the BTComm serial port.

User::LeaveIfError(commport.Open(server,commname,ECommExclusive));
 
 
//Configuring Port is done by using the code 
 
        TCommConfig cBuf;
	TCommConfigV01 &c=cBuf();
	
  // Get the current configuration
	commPort.Config(cBuf);
	
  // Set new settings
	c.iFifo = EFifoEnable;
	c.iRate = EBps19200;
	c.iHandshake = KConfigObeyCTS;
	c.iTerminatorCount = 0;
	c.iDataBits = EData8;
	c.iParity = EParityNone;
	c.iStopBits = EStop1;
	
  // Write the settings out
	commPort.SetConfig(cBuf);

After Succesfull opening of a port can allow to do data transfer. RComm allows you to read and write data over the port. There are several kinds of read and write methods available.

Reading

RComm::Read() reads data from the serial port.

Writing RComm::Write() writes data to the serial port.

iComm.Read(iStatus, iBuffer);
//iComm is the instance of RComm opened earlier.
iComm.Write(iStatus,iBuffer);

Cancelling

You can cancel a pending Read() or Write() using ReadCancel() or WriteCancel().

iComm.ReadCancel(); The TRequestStatus of the pending Read(), or Write() will be set to KErrCancel.

Close the serial port is done using RComm::Close():

iComm.Close();
 
//Closes the serial port.
Related Discussions
Thread Thread Starter Forum Replies Last Post
About the internet connection and RS232 communication wu_genqing General Symbian C++ 0 2002-10-19 08:20
Local Synchronization thierrythevoz OMA DM/DS/CP 1 2002-10-29 18:59
Bluetooth Sensor Communication halifax Python 2 2007-07-12 14:58
Infrared SDKs on PC side hanhikos PC Suite API and PC Connectivity SDK 2 2003-02-11 06:19
7650 working with Acer USB dongle antmanes Bluetooth Technology 1 2003-07-10 13:01
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZbluetoothQ
     qfnZtopicQUqfnTopicZconnectivityQ
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX