Namespaces
Variants
Actions

How to connect to a particular Bluetooth address

Jump to: navigation, search
Article Metadata

Article
Created: mahbub_s60 (10 May 2008)
Last edited: hamishwillee (26 Jul 2012)

Overview

This code snippet shows how we can connect to a Bluetooth device over RFCOMM when we know the address. If we know the address and channel number of interested service then it can be connected directly. If we don't know the channel number then we need to find it as usual way and then we can connect.

   TBTDevAddr devAddr(MAKE_TINT64(0x0019, 0x79fa2193));
// 001979fa2193 is target BT address divided into two parts
 
TBTSockAddr asocket;
asocket.SetBTAddr(devAddr);
asocket.SetPort(5);
//Assuming the expected service is advertised on channel 5

When Channel number is not known

   TBTDevAddr devAddr(MAKE_TINT64(0x0019, 0x79fa2193));				
iState = EGettingService;
iStatus = KRequestPending;
iServiceSearcher->FindServiceL(iStatus, devAddr);
SetActive();
This page was last modified on 26 July 2012, at 05:39.
132 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved