Re: bluetooth device connectivity

24 views
Skip to first unread message

John Langhauser

unread,
Jan 25, 2013, 4:32:52 PM1/25/13
to collaborhyth...@googlegroups.com
From what I understand the model for most of the bluetooth devices is for them to connect to collaborythm (ie having them run in some sort of non-slave mode or having them in a slave mode that attempts outbound connections anyhow).  My question is: how does a bluetooth device know what remote address to connect to?  Collaborhythm could be running on any number of tablets, all with unique MAC hardware addresses.  To my knowledge, bluetooth modules require this unique address to connect.  How should this hookup go?  Are there best practices to ensure a good user experience?

Scott Gilroy

unread,
Jan 25, 2013, 5:01:07 PM1/25/13
to collaborhyth...@googlegroups.com
John Moore is more of an expert on the subject of connecting hardware to CollaboRhythm.

My understanding is that typically you would do something on the bluetooth device to initiate a bluetooth pairing process, and then on Android you can choose to pair. Once paired, the bluetooth device and Android device will remain paired. If they are disconnected or powered off they will automatically reconnect when they are back in range.

Note that we are using a service on Android called CollaboRhythm.Android.DeviceGateway which handles the bluetooth connection and then sends data to CollaboRhythm. See the following code:

John Langhauser

unread,
Jan 25, 2013, 8:17:01 PM1/25/13
to collaborhyth...@googlegroups.com
Any chance John could chime in to confirm that he has setup hardware to do that?  Pairing and connecting to create a new socket are two distinct things, and I haven't found the mode in bluetooth that will auto connect to any paired device (although maybe it does exist).  I am familiar with the android background service and have written my custom socketthread to handle the data transfer between my device and the android service.  What I haven't nailed down is how the initial connection will be made.  Does your answer mean that you can never pair a device with two apps if one of them is collaborhthm (because how would the device know which one to connect to in that case?)

John Moore

unread,
Jan 26, 2013, 12:13:20 PM1/26/13
to collaborhyth...@googlegroups.com
John,

Here is a summary of what we do with other devices:

1. Use a bluetooth module that supports the Serial Port Protocol and that supports a mode where the module can "connect" to a bluetooth socket server using the serial port protocol. I believe that this is called "Master" mode. (Many bluetooth modules by default are waiting to "accept" for a connection from another device. I believe that this is called "Slave" mode. There may be some more nuances to this.
1. Pair the device with Android using the native Android bluetooth pairing process. 
3. When your device takes a measurement, initiate a connection with the paired device, usually by calling a "connect" method 
4. Create a custom thread class for AndroidDeviceGateway for your device that handles the parsing of the data from your device.

It sounds like, from your second e-mail, that you are now able to make the Bluetooth Serial Port Protocol connection with the bluetoothSocketServer in the AndroidDeviceGateway. Is that true? Sorry that I did not get to this e-mail until now. Outside of the Health and Wellness event, I am usually checking e-mail all day long. During the event, however, I am doing team coding and mentoring all day long. Hopefully we can sit down and make this work today. Or, if you can't come in, we can do it in a google hangout with screen sharing.

I have responded to your other e-mail as well about what to do in CollaboRhythm to handle the data that is passed over from the AndroidDeviceGateway. I have copied the text below for reference for others.

John


This functionality is part of the pluggable architecture of CollaboRhythm.

Use ForaD40bHealthActionInputControllerFactory as an example. It is used to support a ForaD40b Blood Glucose / Blood Pressure monitor.

1. Register a HealthActionInputControllerFactory for your device in your PluginModule. In your case, this is the "HypertensionPluginModule"
2. Create this HealthActionInputControllerFactory, which implements IHealthActionInputControllerFactory. One of the methods of this interface is called createDeviceHealthActionInputController. Use some conditional statements to inspect the urlVariables that you send from the AndroidDeviceGateway to CollaboRhythm to make sure that the data coming in is from your device.
3. If the conditions are met, create and return a HealthActionInputController that will determine what to do with the data from your device. This should extend HealthActionInputControllerBase  and implement IHealthActionInputController




--
You received this message because you are subscribed to the Google Groups "CollaboRhythm Developers" group.
To post to this group, send email to collaborhyth...@googlegroups.com.
To unsubscribe from this group, send email to collaborhythm-deve...@googlegroups.com.
Visit this group at http://groups.google.com/group/collaborhythm-developers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages