How to stream data via BLE? - c

I am currently evaluating the board of Maxim Integrated MAXREFDES100#. As part of my thesis, I would like to examine whether there is the possibility of using BLE for data streaming.
The supplied software is fully functional and can already transfer data. Of course, only smaller data packets over a longer period like Temperature or precalculated Heart Rate values. I am aware that BLE is not suitable and has not been designed to transmit data continuously. Nevertheless, I would like to try to transfer the ECG raw data also via the BLE interface. So that I can check whether my data has been arrived completely and correctly in time (prerequisite for ECG data), I have developed the following test setup:
Currently, I store data of a sine wave to a large FIFO and transfer 20-byte sine packets to a characteristic. So far everything works wonderfully. Using an Android device and a BLE sniffer I catch the data packets and check if the sine has any interruptions. The following graphic is taken from a longer measurement: (I have tested my FIFO and the sine datas are complete without any inerruption): This is a capture of my Android and my BLE Sniffer: Data packets are missing.
Sine & Spektrogram Image
Further measurements show that the errors do not occur sequentially, they can always be found at different times. (The Fifo Implementation must be correct)
Sine & Spektrogram Image 2
Since my phone and my Adafruit BLE sniffer have identical errors in the same place, the data packages on the board-side must be corrupt. I suspect they are lost at some protocol level (GAP maybe?). Interestingly, errors affect at least 200 following bytes (256 bytes data are a complete sine). This means that at least 10 data packets each 20 Bytes would have to be in order to get such a graphic.
What options are there for continuously sending data via the BLE interface?
Is it possible to send the data directly via L2CAP without GATT/ATT?
Are there any more wireless, low power protocols that allow data streaming? (So ​​with acknowledgment like TCP for completeness and chronological correctness)
Best regards, Emin

What options are there for continuously sending data via the BLE interface?
Is it possible to send the data directly via L2CAP without GATT/ATT?
BLE v4.1 introduced LE Connection-Oriented Channels which is a way to send data directly via L2CAP without GATT/ATT (think about network sockets). See also Bluetooth Core Specification Vol. 3 Part A Section 3.4.
The board you are using has a EM9301 BLE chip which seems to support BLE v4.1. However, the mbed library you are using doesn't allow you to use them. See here, you have an interface for connect/disconnect callbacks and GATT characteristics read/write/notification. Nothing about LE Connection-Oriented Channel.

Related

How to send data from one ESP32 to another not using WiFi

I'm currently trying to send a small data (like 10bytes) from one ESP32 board to another. The preferred architecture should be that many 'slave' nodes sends data to one 'master' node. All nodes are ESP32 microcontrollers and the max distance is ~3m.
I already have implemented this architecture using WiFi 'HTTP_GET' requests, but as I also need that each node scans for BLE beacons and gets the RSSI value.. the ESP32 flash memory was not enough...
The following error was thrown:
Sketch uses 1661386 bytes (126%) of program storage space. Maximum is 1310720 bytes.
That is the main reason why I want to avoid using WiFi library. Note: I tried to use sub-header files of WiFi.h but that was not enough.
Question
Is there a lightweight implementation to simply send a small amount of data from one ESP32 to another using, for example, BLE signals ? If yes, would be nice to see the code sample!
Edit
I resolved the memory problem. As it turns out, by default the ESP32 is not configured to use the full flash storage capacity. By minimizing the SPIFFS partition helped, now the sketch uses 84% memory storage! But the question still remains.

Data transfer using xbee and arduino

i have a portable device that consist of
arduino leonardo board,xbee series 2 as router( AT mode ) and different sensors.This portable device acts as a remote device and can be used upon power up.
The other side, i have a host controller that consist of arduino uno board, arduinoxbee shield v1.1, and xbee series 2 as coordinator( AT mode ). This host controller is plug through USB into my PC.
The aim of my project is to send the sensor data from the portable device using xbee wirelessly over to my host controller and displaying out on the arduino serial monitor.
I've managed to configured the two xbees. But now, i'm unsure of how im going to transmit and receive the data. I need a transmitter and receiver program for both xbees that is connected to the arduino. Anyone can help please?
There are a couple different options for how you can do this, but the simplest is to set up your sensor XBee either in change detect (IC) mode, or set a sample rate (IR). In either case you'll need to handle the RX Indicator frame at the controller, which will contain the sampled data.
I wrote a C# stack that can configure all this, but for what you're trying to do it would probably only be useful as a reference (https://github.com/jefffhaynes/XBee).

A simple implementation of serial communication between two software entities (Uart / I2C / etc.)

I've done many projects that include a PC & an arduino / PLC / some kind of other microcontroller / processor, and in every project we had a different protocol used for communication between the PC application and the embedded one. Usually the hardware / controller developer invents a simple protocol which always changes throughout the project, and goes into the form of
Barker | Size | Data | Checksum
This time I'm implementing both sides, so I figured - This has been done a million times before. There must be a base protocol for these things with implementations in C, C#, Java, and such.
What I'm looking for is a lightweight layer that transfers stream based serial communication into a message based one.
I've been looking around for one for a while, but I couldn't find anything on my own.
Do you happen to know one?
I had exactly the same requirements for a recent project and I found nothing simple enough for low-end 8-bit microcontrollers. So I designed MIN (Microcontroller Interconnect Network) to do the job (inspired by CAN and LIN).
The code is on github here: https://github.com/min-protocol/min (check out the wiki there).
I defined a layer 0 (the UART settings) and layer 1 (the frame layer, with checksums, etc.) plus a C API.
I'm also working on a higher layer that formally defines how sensor data (temperature, pressure, voltage, etc.) are packed, with a JSON representation and a tool to autogenerate the embedded code to pack/unpack them from frames. The end goal is to create a Wireshark dissector that can be clipped on to the serial line and when fed with the JSON will display the signals in human-readable form.
I wrote a blog post showing a Hello World app running on an Arduino board (with an FTDI UART-USB breakout board carrying the data up to my host PC):
https://kentindell.wordpress.com/2015/02/18/micrcontroller-interconnect-network-min-version-1-0/
This serial problem occurs so often that it would be nice if we as a community just nailed it rather than keep re-coding it for every project.
Check Open Source HDLC
I recently came across MIN - never used this one though
Also check this
Simple serial point-to-point communication protocol
Using X/Y/Z MODEM protocol must be a good choice to solve your problem. It's easy to implement and ready-to-use. I use X-MODEM on an ISP tool communicates with our cortex-m0 powered MCU, and it works pretty well.

GSM AT command response in between downlink data

I have a weird problem that I can't figure out in SIMCOM900A, I am receiving downlink data of about 1080 bytes every 5 seconds, meanwhile doing other things like sending data to server. However, sometimes AT command response comes in between downlink data. Like below:- ## to ## is my downlink packet but I receive AT+CSQ response in between!
##10500000110483&A8813&B182&C1027&D~OTA_S|True|InProcess|182|YCrOK/Uei1R/CKZSAmV+EkjvShKck+ko7zPYP0y7vULiXaPY6H6FeJx47QtXM+0+vAInJ7svI9nQVljeKO9oaDmPU5Qp6p2Yp2GSGbMlvqJhshlTEpcH+6dG759Oev/YBfoNYPg76IG7Ufd1hl7msQshJvQLCdcvYuZKv1xfSFH0xcUR9EVU7UBQO8CYP0HIPQb98JhhvJ6XqrVHQph+6JSq6YcEmCU9YG7ANaaHpX7Q+CXq/C7W+dmFru6VytvXpyRQbnEoSZDA4jx6MbM4vZjFgb6laHEocUl9JbA4wy8Gjeil6MX1Ae/MeI9zWkItwWgxSOM2VuIWpzNBe3MnpOwocXvDcnH/QsI2xHvUsxeT4RK0pLSvGVvSJ2G+TuZ80L54xfa9mCRu0tt3Pf/doPMt2neo3h6dw2zX46m/NdvVmfVCS9muTL3tLtHbziEs0TzA8H28w2m9nCB1htF0H/RRsvcBWeuhTuC3XAn5A3eCZN6LQKNjLEGCdcHdSDmP1bOD/D5bF/QCaS8GnWCYNewnN1uLenUx2MCiVM0GXgo28LKw9cK7gA81rBcuM60XBlNOM64XRhCkBbIus1gvXBZhvXAptLYPpHDZuJ95qd76LblmuFRfM7SlP3/NcJlpzWCUM8lCTqs1w+nkbJl1w6X6usEs55msGy4zrRseMMjZPaqcoeuG08l6JmuHS/W1g1mSM1s7aOPcNl4b54kwzruE+Xqtx2u+XiL4el2gfWOp0ddrO16bv33CfL2O4618vT5gZ26N4OshdpPw2nhc89rw7nbh6/F40NeLmqtnH7jrf9a+Xh9dvr5h+x4DATuf7Xb0hTLw18EwxnclkHIDNe9K3MraThZt/yfI70bevmvJ0Nh+jD+FGgzzXsP6SNM190O6wQZd08+ka26knGbUNU8SpAWy+lnomn6WumbIzGvEWvZaGI99WlzHXKvrmOv
+CSQ: 10,0
OK
OQsf0M+kYo3xJFvKF65jI8rWMbrlW1y3XnYVu6WfS~##
Any suggestions as to why this is happening or how to fix it are welcome! Thanks in advance.
This is a configurational issue. Basically with SIMCOM900A you are limited to two serial interfaces if my memory serves me right. One for AT commands and modem control, the second for debugging.
As you have setup a data connection via the AT command interface it is effectively sharing the interface for incoming/outgoing data communication and modem control commands. What you are seeing with the +CSQ messages are unsolicited (URC) result codes.
You basically have two options:
1) Make use of multiplexing via GSM 07.10 which your modem supports. These then connects to your modem and configures using AT+CMUX so that you will have effectively two ways of connecting to the same serial device.
Thereafter you can use one for managing the modem and sending/receiving AT commands and responses. And the second for receiving/sending pure data (you can also execute AT commands in this channel but there are limitations).
2) Modify your host program/script to cope with this situation and make decisions on what to do based on whether it is data or AT command responses / unsolicited response codes.
NOTE: A word of warning regarding multiplexing. By multiplexing you will end up degrading the performance of communication between the modem and host.
NOTE: It makes real sense always to have a good read through of your modems manual regarding interfacing and AT commands. Manufacturers are renowned for implementing slightly differently compared to the GSM specs :)

How can I send data packets into the network without using sockets?

I want to send data packets into the network bypassing the Linux network stack. I mean is there any way where I can interrupt the network card driver and place a frame in the network card buffer directly to send it in the network? I am a newbie in Linux Kernel hacking so any guideline on how I can get started will be very helpful.
You would be better off if you used some virtual device like TAP. You can easily hack a control interface into the TAP kernel module, via which you can then pass frames ready to be sent out to the driver. That approach can be compared to the performance of a regular socket application as the baseline. Since in the end the TAP device will "send" out egress frames via a character device, you can easily write a test application measuring performance and latency.

Resources