ravey72
Posts: 14
Joined: Wed Nov 30, 2005 11:49 pm
Location: United Kingdom

BlueTools running in Windows Service

Thu Feb 02, 2006 10:44 pm

Hi

I'm evaluating the use of BlueTools running from a Windows Service written in C#.NET (running on a PC)

The service wakes up every few minutes creates a serial port service and receives some data from a bluetooth device.

I'm concerned about leaving the stack drivers loaded as I understand they might affect other bluetooth devices.

I used Manager.GetManager to load up bluetools, and then used Manager.GetManager().Dispose() to unload bluetools, and then put the Windows Serice to sleep for a few minutes.

I then used Manager.GetManager() again when the Windows Service woke up but received an exception indicating that GetManager() can not be called after Dispose as been called.

I would like to purchase BlueTools and use it in a continously running Windows service, but am concerned about the implications of leaving the libraries loaded whilst the service is sleeping. Is there any way around this, or indeed do you see any problem with leaving the libraries loaded? Could it have cause problems with other bluetooth device communication?

Thanks
Kind Regards
Rav

User avatar
johan
GpsGate
Posts: 15342
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: BlueTools running in Windows Service

Thu Feb 02, 2006 11:02 pm

You cannot recreate the Manager once you have disposed it. You are not suppost to call Manager.GetManager().Dispose() until you don't want to use BlueTools at all in your application - normally at application exit.

BlueTools will only hold the resources it needs. If you advertise a service, BlueTools will allocate some resources, if you deadvertise the service all resources will be left back to the OS.

When the mananger is "idle" it will not allocate any Bluetooth resources at all.

It is true that many Bluetooth chips has limitations on doing several things at the same time. But calling Dispose() is not the solution.

Regards,
Johan

Franson Support

ravey72
Posts: 14
Joined: Wed Nov 30, 2005 11:49 pm
Location: United Kingdom

RE: BlueTools running in Windows Service

Fri Feb 03, 2006 2:33 pm

Hi

Sounds like BlueTools might be the one to use.

I was running some tests yesterday and realized that there might be many SerialPort Services exposed by my PC, by many different applications unrelated to my application.

My mobile phone application discovering my PC will look for Serial Port Services and could find several Serial Port Services, exposed by the different applications.

My question is how would you handle such a situation, how does the Mobile make sure it sends data to the Serial Port Service exposed by my application and not any of the others?

I assume the Serial Port service created by my application could have a different BT URL address each time it's created, so I can't send to a fixed address?

Any help will be much appreciated to make my decision.

Thanks
Kind Regards
Rav

User avatar
johan
GpsGate
Posts: 15342
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: BlueTools running in Windows Service

Fri Feb 03, 2006 2:46 pm

I guess there will be a (human) user controling the Mobile ? He could make sure he selects your serial port service for example by name. You can control whech name the service gets when you advertise it.

If you want a more automated approach, you can control wich SCN (Service Channel Number) the service gets.

The chosen approach dependeds on what kind of solution you are making and how the Mobile is used, and what kind of control you have over it.

Each service also has a unique UUID assigned to it. However this will be automatically set by BlueTools in the current version and cannot be controlled by the application.

Regards,
Johan

Franson Support

ravey72
Posts: 14
Joined: Wed Nov 30, 2005 11:49 pm
Location: United Kingdom

RE: BlueTools running in Windows Service

Fri Feb 03, 2006 3:05 pm

Thanks for the very quick response.

As you say there will be a user controlling the Mobile.
If I can set the Service Name and also the SCN then it sounds like the Mobile should be able to automatically discover the service by Service Name & SCN?

Can you direct me as to how to set the Service Name and SCN?

Thanks
Kind Regards
Rav

User avatar
johan
GpsGate
Posts: 15342
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: BlueTools running in Windows Service

Fri Feb 03, 2006 3:08 pm

You set the name in the LocalService constructor.

* CORRECTED*
You set the SCN by
Server.Advertise(objLocalServer, x);

Where "x" is a value between 1 and 255 or 0 (default) for automatically assign a SCN.

More info in the reference manual.

Regards,
Johan

Franson Support

ravey72
Posts: 14
Joined: Wed Nov 30, 2005 11:49 pm
Location: United Kingdom

RE: BlueTools running in Windows Service

Fri Feb 03, 2006 3:43 pm

Thanks.

I tried setting the SCN but compiler suggests that it is a readonly property?

have following code:
m_service = new LocalService(ServiceType.SerialPort, "MySerialService", "My Serial Service");
m_service.Address.ServiceChannelNumber = 67;

Error: Property or indexer 'Franson.BlueTools.Address.ServiceChannelNumber' cannot be assigned to -- it is read only

Any ideas, perhaps it is only the name of the service I can set?

Thanks
Kind Regards
Rav

User avatar
johan
GpsGate
Posts: 15342
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: BlueTools running in Windows Service

Fri Feb 03, 2006 4:47 pm

Yes, stupid me.

You set the SCN by
Server.Advertise(objLocalServer, scn);

You got more info about Service.Advertise() and how to set a specific SCN in the reference manual.

Regards,
Johan

Franson Support

Return to “BlueTools”