Page 1 of 1

Save Settings in register

Posted: Tue Nov 22, 2005 4:40 pm
by Francisco
I am trying to save the setting in the register using visual studio 2005 net for small devices

I want to save the Bluetooth device and service so next time I start my application I don't need to search for a device.

Do you have any idea how to do that

Thanks

Francisco

RE: Save Settings in register

Posted: Tue Nov 22, 2005 6:39 pm
by johan
In beta7, you will need to do a discovery and then compare the addresses of the discovered devices and services with the one you are searching for.

Beta8 will include support for connecting without making a discovery first.

Regards,
Johan

Franson Support

RE: Save Settings in register

Posted: Tue Nov 22, 2005 11:02 pm
by Francisco
as a work around i save it in a text file and then retrive it but i try to use the following code but it givem an error
'<font color="red"> value of type string canot be conveted to Franson...."</font id="red">

Try
' Create an instance of StreamReader to read from a file.
Dim sr As StreamReader = New StreamReader("GEM.txt")
Dim line As String
' Read and display the lines from the file until the end
' of the file is reached.
remodev = sr.ReadLine()
remoser = sr.ReadLine()
remote_device = remodev
remote_service = remoser
sr.Close()
Catch ex As Exception
'Console.WriteLine("The file could not be read:")
'Console.WriteLine(e.Message)
End Try

Any sugestions?

RE: Save Settings in register

Posted: Wed Nov 30, 2005 5:52 pm
by johan
From beta8 and later you can connect to a remote device or service without doing a discovery first. You need the device's address and the service's channel number to do this.

Let's say you made a device/service discovery and found a service you later want to reconnect to without making a (slow) discovery process.

To save

Code: Select all

Dim objService As RemoteService
Dim strAddress As String

' Code to discover a service
' See samples in SDK
' ...

' Service address as a string
strAddress = objService.Address.ToString()

' Here you can save this string to the registry or a file or...
To reconnect:

Code: Select all

Dim objDevice As RemoteDevice
Dim objService As RemoteService
Dim objAddress As Address
Dim strAddress As String
Dim objNetwork As Network

' Place some code here to read the saved address string and set 
' strAddress to this value
' ...
' Then we create a Address object from ' the string
objAddress = new Address(strAddress)

' And place some code here to get a Network object (see SDK samples)
' ...

' Connect to device using its address
objDevice = objNetwork.ConnectDevice(objAddress, "My device")

' Connect to service using its channel number

objService = objDevice.ConnectService(objAddress.ServiceChannelNumber, "My service")

' Now we have a (remote) service object that you can open a stream to...


Regards,
Johan

Franson Support

RE: Save Settings in register

Posted: Fri Dec 09, 2005 4:27 am
by GAMacky
Originally posted by johan

' Connect to device using its address
objDevice = objNetwork.ConnectDevice(addressService, "My device")


Do you mean to use objAddress instead of addressService?

RE: Save Settings in register

Posted: Fri Dec 09, 2005 10:44 am
by johan
Yes, I changed that in the sample code now.

Regards,
Johan

Franson Support