Interacting with BLE Cycle Trainer - bluetooth

My current is on Flutter using Dart and working with Bluetooth low energy devices. I have the basics up using this library and am able to do the following
1. Search for devices and list
2. Connect to device
3. Retrieve services and read characteristic values
4. Subscribe to changes on characteristics.
In order to interact with device correctly I need to read and write from the correct services/characteristics to read data and set things like resistance on the flywheel
I have used the below link and have started mapping out the services, however although the reading can be worked out. The writing to characteristics is a bit out of my reach.
https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.service.cycling_power.xml
The question is.
Does any have experience working BLE cycle trainers and could provide
some insight into how to read and manage services and characteristics
appropriately?

Related

Has anyone used bleak to connect multiple BLE devices and receive notifications from all of them simultaneously?

I am able to use bleak and get data from all 5 BLE sensors. But the problem is that I am unable to identify which data is from which device. I mean i need a string representing the address of the device alongwith the data itself.
I was able to get data simultaneously from all the BLE modules using bleak in Windows, as well as on raspberry pi.
The only problem with Windows is that if you use Bluetooth 4.2 adapter & above. It will be much better for the high speed data rate, and proper devices connection handling. As with the 4.0 adapter, I have always gone through one or two exceptions each time i started the script, and the maximum number of connections I got was 3.
When i tried this script on Raspberry pi 3b+, it has on-board chip of Bluetooth 4.2. It was able to give high speed data rate, and my 5 sensors were connected to it simultaneously.
Also, The two_devices examples in bleak source code on Github, is very good example for starting with further coding.
And if you run the script and found the data on console, but you were unable to get that which data is from device. Then you need to use functools, (what it does is it will inject the client you're connected to at present, with the callback function, and it will make the work much easier).
Check this out on Github: https://github.com/hbldh/bleak/issues/601

BLE sensors pairing and get data

I have this sensors https://lonauto.en.alibaba.com/product/60692809352-806479288/4pcs_Sensor_one_set_intelligent_Tpms_tire_pressure_monitoring_system_free_app_on_iso_android_phone.html?spm=a2700.icbuShop.prewdfa4cf.7.1b29ca9abaaU3n from which I want to get some data over Bluetooth, it's low energy device which isn't discoverable - don't really know how pairing works at all so I need a lot of informations about pairing and everything. Any ideas would be welcome.
They have offcourse official app, but customer want custom app so therefore pairing should be in this custom app.
Bluetooth low energy overview AndroidDeveloperGuide
This guide will help you with creating the logic for connecting and exchanging information from the Sensor.
Please follow all the classes mentioned in the Guide in detail, the various classes' constant variables and methods will give you good knowledge of what sorts of information you can get from the sensor.

Multiple Eddystone-URL/UID's from same Bluetooth Beacon?

Is it possible to program a BT beacon to advertise a sequence of different Eddystone-URL/UID's in sequence? I imagine I could from something like a Raspberry Pi3 with a BT adapter, but I was wondering about something like an actual beacon.
Yes, this is possible. This technique is called "interleaving", and it is possible to do with both software beacons and hardware beacons.
Eddystone actually relies on this technique in order to match its multiple frames. When a receiver sees an Eddystone-TLM frame coming from the same device as Eddystone-URL or Eddystone-UID, it knows that the telemetry is for that beacon frame.
Using the same technique, it is possible to send out multiple URL or UID frames from the same device using different identifiers for each frame. Some commercial manufacturers such as Radius Networks support doing this in some of their products.
I dont think so. Im pretty sure you would need to have some smart device nearby that is running a program that is periodically changing the UIDs. The micro-controllers that power these beacons are pretty bare bones and are really optimized for transmitting bluetooth signals.
Here's how to do it.
EddyStone supports four types of payloads/frame-formats i.e, UID, URL, TLM, and EID.
Eddystone UID/EID are the frame-formats to use for this purpose.
As far as using the 'NordicSemiconductor NRF line' of beacons just make sure that these are fully Eddystone compliant i.e, support the EID frame-format.
Freely available Google Beacon Cloud platform is great for trying this out (called 'registering and provisioning your beacon').
It can be implemented w/o building or requiring any custom app at the client end.
On the client-side.
Use 'Google Nearby Notifications' & 'Google Nearby Messages'
On the server/cloud-side.
Google Proximity API for 'registering and provisioning your beacon'
Use 'Google Nearby Messages' API
Good luck with your project .

Bluetooth data to HID for BLED112

We have bought BLED112 to interface our target via BT.
An android app interacting with target via BT & USB (HID).
We have used some Bluetooth communication to write a program and send data to dongle.
Now can somebody here having any experince in converting that BT data to a HID signal.
Have anybody tried that?
Is there any BGScript code which we need to write to achieve that?
Please let me know if the thought is completely wrong.
Referring to a comment above which states,
We are writing an Android App which can send data to BLED112 over BLE interface or GATT. My question is how can I convert that data (basically a command) to an HID (key event), correct me if my understanding is wrong?
If I understand the use-case correctly, I think, in the initial stages of the development, you will need to use the BLE-GUI utility that BlueGiga provides.
With that utility you can see the communication between the BLED112 Dongle and the BLE112 Module. BLED112 shall be simulating what the android app would do?
First, you will need to know the GATT structure stored in BLED112 to write to or read from the BLED112.
Secondly, the way BLE112 works is an event-based implementation. Going through the API reference document for BLE112 shall help you understand the events generation conditions and codes that are generated modified when a characteristic value is updated by the android application, or read by android application. You get events for connection, disconnection, read from, write to, notification enabled for, indication enabled for, etc.
On the BLE112 side, depending upon what service and what characteristics in that service is going to be used for data transfer between Client (Android App) and Server (BLE112), you need to write suitable implementation in event callback handlers.
There is a standard service called Human Interface Device which has a reserved UUID: 0x1812.
Once you configure your BLE112 as a HID over GATT device, your android app shall see a service with UUID: 0x1812. Parse the service descriptor and get the characteristics bundled up into the service. You can read from or write to that service depending upon access parameters set in gatt.xml
As an example, say, if it is a Keyboard, you can send the scancode for (make and break) of the key depending upon what key is pressed. How to get a scancode is out of the scope of this question anyway, and sadly I had worked on PS2 keyboards, so I don't really know how to get the scancode from a USB keyboard.
So, you have the scancode for the key pressed, and you know the characteristics to write that into. Write it, the application should enable the Notifications for that characteristics, so that it is notified whenever the key is pressed and value is written into the characteristics. To let application enable notifications or indications for the characteristics, study the developer guide that talks about how to write a gatt.xml for Bluegiga-based BLE devices. I'll give you a hint: in xml, in the characteristics configuration you have to write notify="true".
About parsing of the service and characteristics in Android, Unfortunately I am not an android developer, but an embedded developer, I know how the BLE112 module part is to be implemented, while I have no insight of how android parses the data. But, there are plenty of question and discussions about it online, which you might understand better than me since you have an android background.

TI CC2541 (BLE): Send data (to an Android phone)

I am experimenting with Bluetooth Low-Energy (BLE) for the purpose of connecting a hardware device to an Android application. My goal is to send a recognizable piece of data to an Android phone.
I am using the keyfob from Texas Instrument's CC2541 Mini-development kit, and am programming it using the IAR Workbench (which I am learning on the fly). My issue is that I cannot figure out what code should be used to send data from the keyfob to the phone.
I understand that this is somewhat vague, but because of the non-disclosure policies of my company I cannot share the code that I am working with. Does anyone have any references to code for the IAR Workbench that will allow the CC2541 to send a piece of data? Right now, I prefer to use GATT if that helps.
Thanks, and please ask me more questions if I need to clarify anything.
Assuming you're working from a pre-existing service profile, there is a function for every service called ServiceName_SetParameter(). Calling that function will change the characteristic value. When the characteristic is read by the phone, it will receive this value. If the characteristic supports notifications, and your phone has registered for notifications on that characteristic, the new value will be transmitted whenever SetParameter is called.
You can implement any proprietary protcol to connect to and interact with your beacon device. It can assume other roles than just the beacon task. It can also listen to and respond to connection attempts thus expanding into a lot more than a regular beacon.
If you study the cc2541 close you realize it is a pretty advanced IO controller that offers a lot of IO signal possibilities. That way you could use the cc2541 as the heart of an IO control application where you measure and control equipment. Mobile apps can then easily connect to your beacon/IO Controller device and interact with the machinery it is hooked up to. As you see, it´s a remarkably versatile system on chip and a cool circuit to learn to program.

Resources