Does somebody has experience with implementing the MbedTLS with the BLE devices. I have few questions about setting up the read and write call back functions for the mbedtls_set_bio() functions. I wanted to use the GATT api functions to set up the tunnel with MbedTLS. I am completely new to the mbedTLS and the BLE. I am not quite sure about how to set up these call backs and what exactly they should do. I am using the dialogs DA14695 USB sticks to implement the DTLS handshake between the two BLE devices.
Thanks in advance.
Related
I have a BLE temperature sensor, which should send measurements to an ESP32 via a BLE connection and my plan was that the ESP32 could send the measurements via WiFi to my database (Firebase Realtime Database). However, I have seen from a few tutorials that a mqtt server would be neccesary (see the screenshot below - link to the video: https://www.youtube.com/watch?v=PBYCG-ypvRY). Could someone please explain to me why the mqtt component is neccesary? Currently I am measuring temperatures using my ESP32 (without the BLE temperautre sensors) and sending them directly to the database, so I am confused as to why with BLE I would need a mqtt server.
Thanks for your help in advance!
You don't need MQTT. It's just one of the IoT-friendly protocol alternatives (like HTTPS, AMQP, CoAP, homebrew, etc) available to you for device-to-server communication. There are pros and cons to each one. It's up to you to choose whatever solution is relevant to your system.
If you've already implemented the Firebase HTTPS interface and it does the job, you're done.
If you are having problems, note that the Google IoT Core also prescribes MQTT (or, alternatively HTTPS) as an underlying messaging protocol - used together with the Device SDK for Embedded C. But this is for people who want to have a large-scale authentication and management solution for their devices. By all means, stick to your existing solution if it works.
I am trying to implement a DTLS handshake between two BLE devices. For this, I wanted to use the L2CAP channel of the BLE to communicate with the messages coming from the DTLS. Basically, I want to open a DTLS tunnel with the help of L2CAP from the BLE stack. I am using the mbedTLS library for this. From the documentation of MbedTLS (https://tls.mbed.org/kb/how-to/how-do-i-port-mbed-tls-to-a-new-environment-OS), I understood that I need to set the mbed_tls_ssl_set_bio() function which has the read and write call back functions that communicates with the BLE top layers(L2CAP). I am using the dialog's DA14695 dongles for the implementation. I am not very sure about the read and write call back functions that needs to be written to communicate with the L2CAP channel of the BLE. Somebody experienced with opening a TLS/DTLS tunnel with the BLE top layers can help.
Thanks in advance
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
I would like to detect a beacon and then write a value to some of its GATT characterictics, so other BLE-devices can read it. Is this possible at all? Or some special device is needed for this?
This is not possible with a standard iBeacon because it is a transmit only device.
You might be able to build your own custom device to do this, but making it work on iOS when more than one Bluetooth device is around will be almost impossible. This is because there is no way to correlate detected iBeacon identifiers with as connectable Bluetooth device -- iOS has sandboxed the CoreLocation iBeacon detection APIs and the CoreBluetooth APIs needed to read and write GATT characteristics.
As a result, you can never know for sure if you are writing to the same device you detected.
For a detailed explanation of the sandboxing of the CoreBluetooth and CoreLocation iBeacon APIs, see here.
I want to develop a c client library for MQTT, to make my PIC 8 bit micro-controller to talk to an MQTT broker( say Active MQ). I am relatively new to this field. Can anyone suggest where can i start . I need to implement just CONNECT, SUBSCRIBE,UNSUBSCRIBE, PUBLISH nad DISCONNECT API's to start with.
Thanks in advance
You need to get ethernet working first, then just implement the protocol... :)
A good place to look would be the arduino client (http://knolleary.net/arduino-client-for-mqtt/) that should have solved a lot of what you need to do.
Good luck!
I'm really not sure a AMQP client would be able to run on a limited system like the AVR (but a great system tough).
You will need at least the following:
- The TCP/IP stack;
- Enough memory to hold some frames (4096 bytes or maybe smaller but not often);
If you think the arduino will handle all this, I would start from the rabbitmq-c library and strip it down.
Other option, and if the rabbitmq-c isn't small enough, and your goals are just to publish messages, take a look at STOMP and how to combine it with RabbitMQ or other AMQP. Stomp has a very small footprint and will, probably, be the best shot to give.
Cheers,
You can use XSockets.NET since you can connect any device with TCP/IP to XSockets and then talk to other devices.
It will basically work like this.
Setup a XSockets server somewhere (localhost to start with)
Connect from the Arduino to XSockets
Use XSockets publish/subscribe pattern do send/receive data between arduino and any other device connected to XSockets
Simple vide demo here: Arduino pub/sub with XSockets
If you want to mix in any other tech do it from XSockets since that wil be easier than writing stuff on the Arduino.
EDIT: Just saw that you did not say Arduino... 8-bit PIC micro-controller might be another story :) I have just connected Arduino and Netduino