Which GATT Profile and Services are used by OBD BLE Adapters like LELink, Automatic, Carista? - bluetooth-lowenergy

I am exploring building apps (Android & iOS) for Car OBD2 Adapters that support BLE (Bluetooth Low Energy). In order for the app to be able to work with such adapters from different vendors, I presume there would be a standard set of GATT profile i.e. Services and Characteristics that these adapters would be using for standard features like engine RPM, Fuel level etc. Is this info available somewhere that I can refer while building the mobile app?

OBD2 BLE adapters don't use any fixed GATT profiles. The way most (if not all) BLE OBD2 adapters work, is that they offer one service with one or two characteristics:
A write characteristic. This one is where the mobile device can write its AT commands (in the case of, e.g., an ELM327) and PIDs to.
A notify characteristic. This is the one where the results from the car (ECUs) are returned.
Once you have access to these characteristics, you can implement the OBD2 serial protocol (e.g. using a command queue that writes and waits for the response, before transmitting the finished command to the application layer).
Some BLE adapters merge these two into one characteristic. If you want to support arbitrary adapters, you will have to add a 'select your adapter' screen where you probe the found adapters, remember the characteristics, and then communicate.
That way it's possible to write apps that work with all kinds of BLE OBD2 adapters, and not only support a selected handful of vendors, e.g., such as OBD2 Expert (Disclaimer: I'm the author of that software).
Hope that helps!

Related

How do I program this BLE location tag?

I bought one of these:
https://www.aliexpress.com/item/Smart-finder-Key-finder-Wireless-Bluetooth-Tracker-Anti-lost-alarm-Smart-Tag-Child-Bag-Pet-GPS/32806261079.html
As far as I can tell it is a BLE (Bluetooth Low Energy) location tag.
I downloaded the app for it onto my iphone, and the app instantly recognised it and connected to it. The iPhone app seems to know how far away the tag is - it has a little map of the local area and says how many feet away. I was able to set the device name via the app, but I'm not sure if that set it locally or on the tag itself. The iPhone app also has a "find" button - when you press it, the tag beeps.
So I want to know how I can program this thing myself. I want to be able to identify it when it is nearby, connect to it and make it beep. I've searched for quite a while but not come up with much.
I'm assuming (wrongly/rightly?) that there is some general standard or approach for talking to these BLE location devices and carrying out the basic functions with them - but what is that standard - where is the documentation?
Does anyone have any idea how to program these BLE location tag devices?
BLE devices typically communicate using GATT, either using standard GATT services, or custom ones. The command to make it beep is probably implemented using a custom GATT service.
For finding out the distance to the beacon, typically the RSSI is used. This is a measure of the received power. It needs to be compared to the output power at the emitter. Usually beacons will put their output power in advertisement data, so it can be used without connecting to them. Here since the app is also able to send commands to the beacon, chances are it keeps a connection to it and has a custom GATT protocol to retrieve the output power.
Here is what I would suggest:
Read up on BLE, especially advertising and GATT. For instance read this for advertising and this for GATT. The full BLE spec is available here but should be used for reference and not introduction
Sniff the communication between your device and your phone. You can see this other answer of mine to get started
Replicate the communication protocol in you own app. For that you'll need to use your target platform's BLE libraries. For instance for iOS it is CoreBluetooth

Doing BLE pairing and communication remotely

I tried looking everywhere to understand how BLE pairing works but unable to find answers. Lets say I have a small device, like a raspberry pi with a BLE dongle. What I'd like to do is to allow BLE pairing and then subsequent communication with a BLE peripheral (such as a BLE temperature sensor) using software only.
My aim is to try and see if I can control the pairing and then getting the temperature, without touching the sensor at all, so that in future, I can just remotely log into the raspberry pi, turn on bluetooth, obtain the temperature reading and then afterwards turn it off again. And in future if I need to obtain the reading again, I'll repeat the process.
So:
Can this "simple" scenario be achieved using some software based control?
If not, then which parts require manual input and then which don't?
The BLE sensor should not be in advertisement mode or broadcasting the information. It should only send the data to paired devices.
Any and all answers appreciated! :-)
Most Bluetooth low energy devices do not require pairing at all so check first that your sensors do have this requirement. If they do then you need to determine which specific pairing procedure is required. Bluetooth defines various ways to authenticate during pairing and these generally relate to the I/O capabilities of the two devices and are called Association Models. In some cases, pairing "just works" (the name of the simplest association model) and no user interaction is required. In others, say if one device has a keyboard but the other has a display and no keyboard, the second device will display a random 6 digit number and the user must key that number into the first device. All of this is defined in the Bluetooth Core specification.
In your case the pairing procedure will be defined for your sesnors in the manufacturer documentation so check there first. Not that you should only have to do this once per device, not every time you want to read the sensor.
Accessing sensor data remotely needs a gateway which I guess is what your Pi will do. The Bluetooth SIG defined a set of RESTFul HTTP APIs for exactly this purpose. See https://www.bluetooth.com/develop-with-bluetooth/white-papers
The SIG also provides a gateway developer resource for Raspberry Pi which you can download including source code which is written in node.js. See https://www.bluetooth.com/develop-with-bluetooth/developer-resources-tools
Good luck

zigbee module talks to humidity / temperature sensor

I just bought a gateway equipped with the zigbee module (zigbee pro stack ). Also, I bought a zigbee humidity / temperature sensor as well.
It's HA profile and humidity / temperature cluster Id.
There is an operating system (WindRiver) running on this gateway.
To write an application to read the value sent from zigbee sensor, where should I get to start?
Is there any document available? like defining the data structure for the temperature / humidity ?
Thanks
Start with the Gateway documentation. The company selling it should provide enough information to you that you can discover devices (like the sensor) that have joined the network, and then discover the endpoints, clusters and attributes on those devices.
The ZigBee Alliance has documentation for various layers of their network stack that you'll want to understand if you're going to work with the ZigBee Home Automation profile.
The ZigBee Cluster Library (ZCL) defines attributes and general functions for discovery, reading, writing and reporting on them. You should have a basic understanding of ZCL as a foundation for working with ZigBee.
For the Home Automation Profile, you may need to join the ZigBee Alliance to gain access to the specification. I wasn't able to find it with some quick Google Searches. It will list all of the attributes, their data types, and what values they represent. From that, you can create ZCL Read Attribute Requests to read the values and process the responses.
Sorry, but without knowing the gateway that you are using it is impossible to know the API and what the functions are for joining, discovering and controlling devices. There is no "Standard ZigBee Gateway API", each gateway will implement its own. Some may offer a high level interface with API's for controlling devices, others will send "raw" messages where you will need to form the ZCL command your self. The ZigBee Gateway here:
Free SW SDK (Z-STACK-LINUX-GATEWAY): http://www.ti.com/tool/z-stack
HW Reference Design: http://www.ti.com/tool/CC2531EM-IOT-HOME-GATEWAY-RD
Has a well documented API with features like:
- Open Network
- Close network
- Device discovery
- Turn Light On/Off
- Read Temperature
- Read Humidity
It has an open source node.js example application which offer a local web interface and connects to a cloud service (this also includes connecting to and configuring reports for humidity and temperature sensors, as well as connecting to and controlling Philips Hue Lights):
https://git.ti.com/zigbee-iot-agent/zigbee-iot-agent
An example JAVA application is also available:
https://git.ti.com/zigbee-iot-agent/ti-zstack-linux-gateway-java-cmdline-example
Regards,
TC.

Are the ZigBee APIs still AT commands?

I'm attempting to get some ZigBee equipment to communicate with each other. I've had some success with the XBee USB, but I have had to switch to Telegesis recently. This piece appears to have a specific AT command set. Will it be compatible with ZigBee sensors made by other companies?
Also - I've run across a few APIs for ZigBee. Are they all just AT commands at the core?
AT commands are just used to configure the Telegesis ZigBee module. It's a SoC and can work in any mode (coordinator/router/zed). On the other side, it talks the ZigBee language and can communicate with any ZigBee certified device. So it can be used to create a ZigBee network or can be included in any ZigBee network.
All ZigBee radios should interoperate -- you just need to make sure they are configured to join to each other. With XBee modules, be sure to set ATZS to 2 so the radios form and try to join a true ZigBee network. The default setting of 0 is for non-ZigBee networks.
To have modules join to each other, you'll need to know the PAN ID and possibly link key used to secure the network.
Once you start communicating via ZigBee, expect to use these modules in an API frame mode, where you need to set address information (destination node, source/destination endpoint, cluster) in the headers.

GATT Profile for a BLE device (server) that switches on/off a LED

Not sure if to posted this on SO.
I'm looking at pretty simple BLE Device. It has a two LEDS (to simplify) that can be switched on or off.
While browsing the GATT profiles, i can't find which profile i should use. Most of them send something back (like a temerature) to the client (upon request).
I need the opposite: switch something on/off of the BLE decive (server). In my case, the client (a iPhone) would send a command to switch on/off LED-1 or LED -2.
What service profile i should use?
Thanks.
I'm using the nRF8001 development kit & nRF Studio for making the services.h
If the LED's are just to be turned on/off there probably isn't any specific profile that they belong to. You probably need to know the handle and write directly to the attribute some value that maps to on or off. Maybe you can figure it out by listing all attribute characteristics. (unfortunately I don't know how to do that specifically on the iPhone)
I noticed that you are using the nRF8001 development kit. So, first thing you need to check is whether the LEDs are connected to IO port of the micro-controller on the kit or directly connected to IO port on BLE chip.
If it connected to micro-controller on the kit then you need to program the kit to handle the received bluetooth data to control led. (It would have a high chance it is in this situation)
If it connected to BLE chip, it means you need to program the ble chip first.
Usually, useful GATT profiles are user specified. It means you need to define the profile yourself. And, I believe some part of the kit or the studio would allow you to do modifications to the profile.
There is only one default GATT profile you should use -- GAP which is to define the defaults like name of the ble device. The others usually are user self-defined profiles.

Resources