I have read in a couple of places (but nowhere official) that you need to use a smartphone to setup and add devices to a mesh. Is that true? Can you not do it with IR or a NFC? What are my options?
Bluetooth Mesh defines the Provisioner as the device that is able to create a mesh network and add (provision) new nodes into the network.
A Provisioner does not necessarily have to be a smartphone, although that will generally be the case. Provisioning is performed over Bluetooth channels - either over advertising channels (using a new protocol defined by Bluetooth Mesh), or over GATT (to support legacy smartphones that cannot advertise custom AD types).
To provision nodes over the advertising channels (the so-called PB-ADV bearer), the smartphone OS needs to be updated to allow developers to implement the PB-ADV protocol. That is not likely to happen soon enough.
Therefore the best option will be to provision nodes over GATT. The unprovisioned node (e.g., the sensor) will have to include the Mesh Provisioning Service in its GATT Database. The smartphone (as GATT Client) will connect and discover this service, and use its characteristics to exchange Mesh Provisioning PDUs.
You can wait until some companies will develop these smartphone apps, or, if you are in a hurry, you can grab the Mesh specification available on the Bluetooth website and develop a provisioning app yourself. The current smartphones' OS allows you to develop a GATT Provisioner (both on Android and iOS).
In general, a phone/tablet class device is needed for provisioning. IR or NFC can be used for OOB authentication, but the full Bluetooth mesh stack is required to initiate and complete the provisioning process.
A good reference as an introduction to Bluetooth mesh can be downloaded from the bluetooth.com web site Bluetooth mesh Introduction for Developers.
At the moment, the best place to start is the Nordic Mesh SDK that uses the Bluetooth SIG mesh. This has an example (for lighting) where a Bluetooth device itself does the provisioning. There's also a 'Serial' example where, again, a Bluetooth device does the provisioning connected via UART to USB that can be controlled via a desktop/laptop. You could extend the examples so that the provisioning BT device has extra GATT services that open up the provisioning to smartphones.
Related
When connection to a custom BLE device from an app (android and ios) I have two options
a) first pair the device on the phone (like a headset or other devices) and then use it from the app to read and write data
b) without pairing on the phone, go inside the app, search for a device with a specific name or address, and just connect to it and read and write data.
when is one preferred over the other one ?
Its just when it needs to interact in the background or am I missing something?
The devices you see in your phones Bluetooth settings are Bluetooth Classic devices. There are some devices using both BLE and Bluetooth Classic which show up in the settings too, but the settings page is only for the Bluetooth Classic part of the device. Headphones for example are streaming music trough the Bluetooth Classic profile A2DP but might offer BLE services for additional features.
You always have to use a special app to communicate with the BLE part of a device. This could be an app provided by a manufacturer or a generic BLE scanner app such as nRF Connect.
As alexander.cpp already told you in his answer pairing (the exchange of keys) and bonding (saving of said keys) is not required for the communication with BLE devices and only needed if the device requires a secured connection.
Bonding (technically correct term for BLE, often called Pairing in non-technical speech) is mostly for security, we can send sensitive information because the receiver is verified and data is transferred in encrypted form.
Prefer to use bonding if the data is sensitive (means users feel uncomfortable if somebody they don't know receive their data). For example, I consider "current temperature = 25" as NOT sensitive. For detailed explanation, find "Bonding with a BLE device" in BLE guide by PunchThrough.
Also this is a good answer to a similar question: https://stackoverflow.com/a/42916081/10380092.
Your second question about background - no, bonding is not related to interaction in background.
Problem
I am currently working on a Bluetooth communication library for Raspberry Pi. It only has to support simple messaging. The main requirement is that is it decentralized
I therefore thought that Bluetooth mesh would be the best solution. I followed this guide for installing the Linux meshctl tool, but I could not find the functionality for sending messages between multiple Raspberry Pi. It seems that the meshctl tool is only for provisioning and configuring Bluetooth mesh networks.
Is this correct? Please correct me if I am wrong, I would love to be wrong.
Solution?
Is Zephyr a viable alternative? It seems that it is currently ahead of Linux when it comes to Bluetooth mesh.
TLDR: Is the meshctl tool for Linux only for provisioning and configuration? Should i use Zephyr instead?
TLDR: Yes, Meshctl is for provisioning only. Better to use Zephyr for regular mesh nodes instead.
Bluetooth Mesh nodes are usually embedded devices and Zephyr is really good alternative for regular node. It is backed by Linux foundation and feature rich implementation. It is also under active development. There are also couple of other open source mesh implementations: Mynewt-nimble and ESP32 but both of them are actually based on Zephyr's mesh stack.
As provisioner you could use meshctl by Bluez or provisioner app on phone (nRF Mesh or Bluetooth Mesh by Silicon Labs).
Zephyr is an excellent choice. The Bluetooth SIG have an educational resource for developers wishing to learn about Bluetooth mesh (includes hands-on project work) and it uses Zephyr. See https://www.bluetooth.com/bluetooth-resources/bluetooth-mesh-developer-study-guide/
You can use the ST BLE Mesh app from STMicroelectronics : https://play.google.com/store/apps/details?id=com.st.bluenrgmesh&hl=en_IN
They have also Mesh fw and Apps SDK which includes (Android library for Mesh and iOS SDK for Mesh).
It not only acts as a provisioner but you can also share the mesh network configuration via email or cloud to another Smartphone.Apart from this they have command set for Many mesh models - GenericOnOff,GenericLevel,Sensor Model, Lighting Model , HSL model and CTL model.
You can drop support questions at : https://community.st.com/s/topic/0TO0X000000BSrIWAW/ble-mesh
I am looking for a way to scan a device I own and discover "what it can do".
In other words, I'd like to know if a device is able to describe the way you have to communicate with it in order to build some application around it.
In my case it is a simple Christmas light that I'd like to play with but this could be used in different situations.
For classic bluetooth (BR/EDR):
When scanning for bluetooth devices (Inquiry), the bluetooth device will send an inquiry response (if it wants to be discovered) and maybe also an extended inquiry response (EIR). This EIR may already contain a list of services, the devices supports. This is a very fast way to get a picture of a remote device.
Moreover, the service discovery protocol (SDP) gives more information on a device. This takes some more steps. In SDP two devices can exchange their capabilites in kind of ping pong process.
For BLE:
After connecting a BLE device usually a service discovery takes place. The BLE peripheral (e.g. headset or a light) reports its capabilities to the central (e.g. smart phone). Some of these services have predefines functionalities. Additionally, it is free to the manufacturer to add custom services.
I want to create a ble custom service so that I can send and receive some small files(~220 bytes) from my smartwatch( bluetooth 4.0) to ios phone using Bluetooth low energy.
Can I get any reference on how to create custom service (as standard services are not used for this) to transfer file?
I am expecting that once connection is established, both peripheral and central are able to receive and send data. Is it right?
Here I want to make watch as central and smartphone as peripheral is it possible?(I cant make watch as peripheral because it will be always connected to some other peripherals as a central, so it cannot be a central and peripheral at the same time )
And the final question is that my assumption to make smartphone as a peripheral and watch as central is correct or not?
( 1.)more data has to be sent from watch to phone.
2.) watch will be already connected other ble devices as a central.)
I am using bluetopia 4.0 stack in watch.
It is possible to create a custom service. See the documentation on 'Performing Common Peripheral Role Tasks' here
Yes, both Peripheral and Central can send and receive data. It depends on the properties and permissions of the characteristics in the GATT service.
The decision to make a device as Central or Peripheral depends on the use case and a variety of parameters like data rate, power consumption etc.
I'm not a ble guru, I worked on some modules to expose some simple service with pairing and bla bla :9
One of our customer ask me if it possible to control mcu gpio, with a beacon service running. For what I know beacon standard is only a lighthouse to check the proximity (streaming simple packet uuid, signal strength etc etc), and the only way to do something like this is to expose a new service running concurrently with beacon ( in practice send multi type of packets). I don't want pairing (beacon<->device app) and don't worry about race condition, if multi devices set/reset a gpio, it's not my business.
I found something similar https://community.estimote.com/hc/en-us/articles/217429867-What-is-GPIO-How-to-set-it-up-, what you think about?
There are libraries or eddystone's extensions to do that? Some project on github?
We prefer to work with Nordic ble module, but if you know solution based on other mcu, you are welcome.
Thanks for your help
Standard beacons (iBeacon, Eddystone, AltBeacon) are transmit only devices. They simply send out advertisements at a fixed rate with a unique identifier. Some manufacturers expose proprietary configuration interfaces as read-write Bluetooth LE GATT Services. But there is no standard GATT Service that does this, and the manufacturer-specific schemes are designed specifically to set beacon identifiers and other operating parameters.
I don't think there are beacon-specific libraries or extensions that will help with this, beyond standard Bluetooth LE SDKs for iOS and Android. In order to accomplish this goal with a Nordic BLE module you would need to build your own custom system:
Write custom Nordic firmware (that sits alongside beacon transmission firmware) that exposes a new Bluetooth LE GATT Service. The service would expose a writable GATT Attribute that would control the GPIO pin.
Write custom mobile app code that connects to this GATT Service (CoreBluetooth on iOS and android.bluetooth on Android), and writes to the GATT attribute to control the pin.
One thing you must be careful of is that connecting to to a GATT Service will typically stop a Bluetooth Peripheral from advertising (meaning it won't transmit as a beacon). So you may wish to drop the connection quickly to prevent mobile devices or other Bluetooth Centrals from stoping the beacon transmissions.