You Are Here:

Community: Developer Discussion Boards

#1 Old Receive over Bluetooth - 2003-11-11, 10:22

Join Date: Oct 2003
Posts: 12
Waldemar_Arndt
Offline
Registered User
Dear all,
i send a String "Hallo" to the Bluetooth Device(BlueSerial-Laptop) the string is comming on. The Devie ist answered but i don't know how i can receive the Strings from my Bluetooth Device(BlueSerial-Laptop) i send the String with the follwing Code.

Can me someone help how i can receive the answer from Bluetooth Device(BlueSerial-Laptop) .

I have try whith the Read() and Receive() functions from RSocket but it was nothing.

Thanks for Your help.



void CBT1AppUi::Init()
{
RSocketServ iSocketServer;
RSocket iSendingSocket;
iSocketServer.Connect();
TProtocolDesc pInfo;
TBool BTFound;
TInt KRfcommChannel;

KRfcommChannel = 1;


User::LeaveIfError(iSocketServer.FindProtocol(_L("BTLinkManager"),pInfo));

RHostResolver hr;
User::LeaveIfError(hr.Open(iSocketServer,pInfo.iAddrFamily,pInfo.iProtocol));


TInquirySockAddr addr;
TNameEntry entry;
addr.SetIAC(KGIAC);
addr.SetAction(KHostResInquiry|KHostResName);
TRequestStatus status;
hr.GetByAddress(addr, entry, status);
User::WaitForRequest(status);

if (status == KErrNone)
{
BTFound = EFalse;
if ( entry().iName.Match( _L("BlueSerial-Laptop") ) != KErrNotFound) //Senden an BT device mit namen MyHandy
{
BTFound = ETrue;
}else{
while (hr.Next(entry) != KErrHostResNoMoreResults)
{
if ( entry().iName.Match( _L("BlueSerial-Laptop") ) != KErrNotFound)
{
BTFound = ETrue;
break;
}
}
}
if(BTFound)
{
TBTSockAddr iBTSockAddr( entry().iAddr);
hr.Close();
User::LeaveIfError(iSendingSocket. Open(iSocketServer,KBTAddrFamily,KSockStream,KRFCOMM));

iBTSockAddr.SetBTAddr(iBTSockAddr.BTAddr());

iBTSockAddr.SetPort(KRfcommChannel);

TRequestStatus istatus;
iSendingSocket.Connect(iBTSockAddr,istatus);

User::WaitForRequest(istatus);

if (istatus== KErrNone)
{
// Write some simple data

_LIT8(Init,"Hallo");// Send Init
iSendingSocket.Write(tgt,istatus);
User::WaitForRequest(istatus);
iAppContainer->Send();
}
}else{
// MyHandy is Off!
hr.Close();
}
}else{
// no bluetoth device
hr.Close();
}
}
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia