Read bluebooth address from file

Login to reply to this topic.
Wed, 2005-03-09 08:40
Joined: 2004-08-25
Forum posts: 32
I have recently write some code to read in a Bluetooth Address from file, But it doesn't work. Can anyone tell me where did I make mistake? and is my file data format appropriate in the situation?

Thanks,
Vincent

Following is my code:

RFs fsSession;
User::LeaveIfError(fsSession.Connect());
#ifdef __WINS__
_LIT(KMyFile,"Z:\\Documents\\Media files\\document\\unfiled\\BTAddr.txt");
#else
_LIT(KMyFile,"c:\\documents\\Media files\\document\\Unfiled\\BTAddr.txt");
#endif
RFile myFile;
User::LeaveIfError(myFile.OpenfsSession,KMyFile,EFileShareExclusive|EFileWrite));
HBufC8* readBuf1;
readBuf1 = HBufC8::NewL(17);
myFile.Read((TDes8&)readBuf1);
iRemoteSockAddr.SetBTAddr(TBTDevAddr((TDesC8&)readBuf1));
delete readBuf1;
fsSession.Close();

My file data format:
00 08 E0 01 97 E6

Thu, 2005-03-10 10:55
Joined: 2004-07-28
Forum posts: 1379
Read bluebooth address from file
Try something like this:

Code:
RFs fsSession;
User::LeaveIfError(fsSession.Connect());

#ifdef __WINS__
_LIT(KMyFile,"Z:\\Documents\\Media files\\document\\unfiled\\BTAddr.txt");
#else
_LIT(KMyFile,"c:\\documents\\Media files\\document\\Unfiled\\BTAddr.txt");
#endif
RFile myFile;
User::LeaveIfError(fsSession,KMyFile,EFileRead));


TBuf8<17> buf;
myFile.Read(buf);

TLex8 lex(buf);

for (TInt i = 0; i < 6; i++)
{
TInt8 tempByte;
lex.Val(tempByte);
iRemoteSockAddr[i] = (TUint8) tempByte;
lex.SkipSpace();
}

myFile.Close()
fsSession.Close();


didster

  • Login to reply to this topic.