C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 06-03-2004, 06:13 AM   #1
Registered User
 
Join Date: Jun 2004
Posts: 5
Store Bluetooth remote address to a text file

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);
labamba is offline   Reply With Quote
Old 06-03-2004, 06:41 AM   #2
and the hat of vanishing
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,214
Odd that you've mastered network programming yet cannot open a file and write a string to it.

How about something like this?
Code:
ofstream foo("foo");
foo << addressAsString;
foo.close();
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Up to 8Mb PlusNet broadband from only £5.99 a month!
Salem is offline   Reply With Quote
Old 06-11-2004, 12:04 PM   #3
Registered User
 
Join Date: Jun 2004
Posts: 5
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?
labamba is offline   Reply With Quote
Old 06-14-2004, 02:57 PM   #4
Registered User
 
Join Date: Jun 2004
Posts: 5
Quote:
Originally Posted by labamba
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?

no worries, there was a problem with the 'include directories' in VC++.

problem is now solved. many thanks for your help
labamba is offline   Reply With Quote
Old 07-09-2004, 06:14 AM   #5
Registered User
 
Join Date: Jun 2004
Posts: 5
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?)
labamba is offline   Reply With Quote
Old 07-09-2004, 06:32 AM   #6
Stinking it up.
 
StinkyRyan's Avatar
 
Join Date: Jun 2004
Posts: 61
Code:
string mac;
ifstream filein("file.txt");
getline(filein, mac);
filein.close();
I don't think that is exactly what you are looking for but I posted it any ways, try rephrasing the question.
__________________
Because I can't.
StinkyRyan is offline   Reply With Quote
Old 07-09-2004, 06:51 AM   #7
Registered User
 
Join Date: Jun 2004
Posts: 5
you are right stinky about the rephrasing:

ok, this text files includes all bluetooth devices that are in range at the moment.
these bluetooth addresses will stay in the file until the next time that I press the search button in order to search for new devices.

I want to show in a graphical way that: at 2.14 pm this file has 3 addresses in it, while in 2.30 pm the text file has 5 addresses in it (after a new search)

how am I supposed to do that?
labamba is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ std routines siavoshkc C++ Programming 33 07-28-2006 12:13 AM
Post... maxorator C++ Programming 12 10-11-2005 08:39 AM
Dikumud maxorator C++ Programming 1 10-01-2005 06:39 AM
Possible circular definition with singleton objects techrolla C++ Programming 3 12-26-2004 10:46 AM
Unknown Memory Leak in Init() Function CodeHacker Windows Programming 3 07-09-2004 09:54 AM


All times are GMT -6. The time now is 08:18 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22