Store Bluetooth remote address to a text file

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2004
Posts: 6
Reputation: labamba is an unknown quantity at this point 
Solved Threads: 0
labamba labamba is offline Offline
Newbie Poster

Store Bluetooth remote address to a text file

 
0
  #1
Jun 3rd, 2004
Hi there!

Using the code below I am able to discover the bluetooth address of a remote host and print it on the screen.

However, I would like to 'get' this bluetooth address, before printing on the screen, and store it in a text file on my PC.

How am I supposed to do that?

Thanks a lot.

The code to scan for other bluetooth devices:

SOCKADDR_BTH *pAddrBthLocal=(SOCKADDR_BTH*)pCSAddrDevices->LocalAddr.lpSockaddr; AddrBthLocal.btAddr=pAddrBthLocal->btAddr



The code to print the remote bluetooth device's address on the screen:

addressSize = sizeof(addressAsString);
if (0 == WSAAddressToString(pCSAddrDevices->RemoteAddr.lpSockaddr, pCSAddrDevices->RemoteAddr.iSockaddrLength,
&protocolInfo, addressAsString, &addressSize)){
UpdateData(true);
Aux.Format("Remote Address: %s\n", addressAsString);
m_SocketInfo.operator +=(Aux);
UpdateData(false);
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 256
Reputation: FireNet will become famous soon enough FireNet will become famous soon enough 
Solved Threads: 6
FireNet's Avatar
FireNet FireNet is offline Offline
Posting Whiz in Training

Re: Store Bluetooth remote address to a text file

 
0
  #2
Jun 7th, 2004
See what you can, remember what you need

Fourzon | Earn via Coding
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 6
Reputation: labamba is an unknown quantity at this point 
Solved Threads: 0
labamba labamba is offline Offline
Newbie Poster

Re: Store Bluetooth remote address to a text file

 
0
  #3
Jun 11th, 2004
thanks and sorry for late replying but i was away for a week.

ok i changed the code in the following way but I get the errors below.

Code:
}
addressSize = sizeof(addressAsString);
if (0 == WSAAddressToString(pCSAddrDevices->RemoteAddr.lpSockaddr, pCSAddrDevices->RemoteAddr.iSockaddrLength,
&protocolInfo, addressAsString, &addressSize)){
UpdateData(true);
Aux.Format("Remote Address: %s\n", addressAsString);

ofstream foo("foo");
foo << addressAsString;
foo.close();

m_SocketInfo.operator +=(Aux);
UpdateData(false);
}

The errors:

error C2065: 'ofstream' : undeclared identifier
syntax error : missing ';' before identifier 'foo'
'foo' : undeclared identifier
<<' : illegal, right operand has type 'char [1000]'
left of '.close' must have class/struct/union type


Am I missing something?
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 256
Reputation: FireNet will become famous soon enough FireNet will become famous soon enough 
Solved Threads: 6
FireNet's Avatar
FireNet FireNet is offline Offline
Posting Whiz in Training

Re: Store Bluetooth remote address to a text file

 
0
  #4
Jun 12th, 2004
Originally Posted by labamba

Am I missing something?
Did you try including fstream.h

#include <fstream.h>
See what you can, remember what you need

Fourzon | Earn via Coding
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 6
Reputation: labamba is an unknown quantity at this point 
Solved Threads: 0
labamba labamba is offline Offline
Newbie Poster

Re: Store Bluetooth remote address to a text file

 
0
  #5
Jun 12th, 2004
Yes,

I have included it... :/
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 256
Reputation: FireNet will become famous soon enough FireNet will become famous soon enough 
Solved Threads: 6
FireNet's Avatar
FireNet FireNet is offline Offline
Posting Whiz in Training

Re: Store Bluetooth remote address to a text file

 
0
  #6
Jun 13th, 2004
ok, then try using it like this.

  1. #include <fstream.h>
  2.  
  3. void main()
  4. {
  5. ofstream file;
  6.  
  7. //your code
  8.  
  9. file.open("log.txt",ios::app);
  10.  
  11. file<<"what erver you want :-)";
  12.  
  13. file.close();
  14. }
See what you can, remember what you need

Fourzon | Earn via Coding
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 6
Reputation: labamba is an unknown quantity at this point 
Solved Threads: 0
labamba labamba is offline Offline
Newbie Poster

Re: Store Bluetooth remote address to a text file

 
0
  #7
Jun 14th, 2004
no worries, there was a problem with the 'include directories' in VC++.

problem is now solved. many thanks for your help
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 256
Reputation: FireNet will become famous soon enough FireNet will become famous soon enough 
Solved Threads: 6
FireNet's Avatar
FireNet FireNet is offline Offline
Posting Whiz in Training

Re: Store Bluetooth remote address to a text file

 
0
  #8
Jun 15th, 2004
Good you fixed it.Now get going onto proper file i/o and log the stuff you need in an organised fasion.
See what you can, remember what you need

Fourzon | Earn via Coding
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 6
Reputation: labamba is an unknown quantity at this point 
Solved Threads: 0
labamba labamba is offline Offline
Newbie Poster

Re: Store Bluetooth remote address to a text file

 
0
  #9
Jul 9th, 2004
Problem continuing...:

Hi there.

Now that i have the MAC address in a text file I was just wondering how I can 'graphically' show the stats of this text file (ie. that the mac address 0A:4h:3e:1b has been recorded 3 times at that time of the day etc.)?

I would really appreciate it if you could help me on this matter.

Thanks a lot


PS Should I change the format of the file (instead of .txt to use a .xml maybe?)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC