I need help to setup my project. In particular, my project is a C/C++ project.
This project involves different components that must communicate exploiting Bluetooth Low Energy.
Components:
The components can be classified into two different categories: a mobile component (such as a tablet android or an Ipad) and a raspberry component (a Raspberry Pi W board with a BLE adapter). In the system, there can be 1 mobile component and from 1 to N raspberry components
Desired Behavior:
According to the project requirements, the Raspberry components should notify their presence in order to be detected from the tablet. The tablet has to scan for nearby raspberry and eventually connect to one of the scanned devices. Once the connection is established the tablet has to send at least two strings to the raspberry.
I downloaded the last version of Bluez and I saw the python scripts in the test folder: example-gatt-server and example-advertising. Unfortunately, I have no experience with python. So I looked for an equivalent C code but didn't find anything.
Can anyone help me to find a GATT server in C able to advertise and receive connection request?
Is it correct for my requirements to implement the code for the Raspberry as the one in the gatt-server-example?
Thanks
[EDIT]:
My boss agrees with me to use these python scripts instead of using some C/C++ equivalent. As said before I have no experience using python, so I need some help.
Which types of data are accepted from the gatt-server? Can I pass a string to it?
If I want to modify two of the implemented services (the ones identified using UUID 12345678-....) to pass a string can I do this?
In the gatt-server example, there is a service that seems to deal with the encryption mechanism. If I try to send the string "goofy" is this encrypted, sent and decrypted once received by the gatt-server?
Thanks
Related
I've managed to write a Python program for my Raspberry Pi that interacts with BLE via D-Bus and can register GATT services and store data in chatacteristics that external devices can read. However, my goal is to send images from my Raspberry Pi (peripheral) to an Android/iOS device (central). I've started searching for information on how to do that and discovered that there is a pretty low limit on how much data can be stored in a GATT characteristic (answers range from 20 to 512 kB). Because of this limit, the larger data must be split into chunks and transferred using a rather complicated algorythm involving GATT notifcations. That made me wonder if I'm on the right path. It looks like an overhead to implement such a complicated algorythm to send an image via Bluetooth and the low data size limit makes me think that BLE isn't meant for this. Maybe I should just use classic Bluetooth with sockets? Or maybe someone can point me to an example of an application which sends image via BLE, because I couldn't find anything useful on the internet. I mainly chose to use BLE because I want to write the Android/iOS application using React Native and it only supports BLE client. Does iOS even support Bluetooth classic?
I am working on a project where I need to detect objects from IP camera on PC using TensorFlow and the data of the detected object to raspberry pi and control its GPIO pins accordingly.
I am using python on both ends.
I read somewhere to form a client-server network between the two.
I need some ideas on how to approach this problem. Thank you. I hope my question was clear.
Extra Information: I am currently using Raspberry pi on PC via ethernet cable. Also, both raspberry pi and my PC are connected to the same Wifi router. I hope this information helps.
You can use sockets to make the Raspberry Pi and your PC communicate. You can use socket.accept(conn, address) to accept a connection and conn.recv(buffer) to receive data.
I'm a big fan of using Redis for this type of thing. It has a small footprint, is simple to set up and is lightning fast. It is a "networked data structure server". "Networked" means that its clients can be on the same machine or anywhere on the network. The data structures it serves include:
strings
integers
atomic integers
lists
queues
sets
sorted sets
hashes
There are bindings for Python, C, C++, PHP, Ruby and rather brilliantly, the shell. That means you can inject values into queues, lists or sets directly from any Terminal on your network whilst your app is running, in order to test it or monitor it.
Example here.
I have two PLC modbus devices. These two are different companies.
The first one is that A will return the temperature and humidity. The second is that B will return five values. In both devices, the connection is modbus TCP.
One problem is that the same test software can be connected but the other cannot be connected. One device can be connected using pyModbus, but the other device is not working.
I also tested some software and python libraries. List is as follows
Device A
Software
modbus Poll (OK)
ModScan32 (NO)
Python Lib
pyModbus (OK)
EasyModbus (NO)
Device B
Software
modbus Poll (NO)
ModScan32 (OK)
Python Lib
pyModbus (NO)
EasyModbus (OK)
I don't know the difference between the two devices.
I want to integrate these two into the web system for monitoring, and new devices can be added in the future.
If there is a third device, I have to retest the connection to see which Python lib is available.
How can I implement this?
Learn more about the communication format of PLC devices?
Write a set of Python Libs for all devices?
Thank You.
Use one library for each, save the data somewhere centralized and view it with a different app. I don't see the problem. Also, have you tried re-trying the connection or reading after a few seconds? In my experience, modbus devices fail every so often to answer (or maybe is a library problem, I don't know) and a retry usually works.
For this, and it sounds like any good IOT framework would solve it, you should send the data from each device separately to one central point, like an IOT cloud solution, then you can build a webapp to view whatever data you have on the IOT framework, regardless of when or if it came in. Most frameworks will show you the old data as well if its not connected, so you can still display data, indicating it is stale or something to your user.
First, thank you all for your useful posts. I can usually find what I need from SE without needing to make a post.
I'm hoping to make a timer/sensor device that I can control from a web browser.
I'm planning to hook up a set of sensors by USB or pinouts to a Raspberry pi, then having the Pi host a web server. I have experience writing web servers from scratch in python, so I intend to use python as my programming language for this application as well.
I want to be able to visit the server from another device that will run at a time-keeper's station. By selecting options on the web site, you could control the display portion of the timer or the values of variables (timer reset) also the sensors could trigger update events to show information on the web page.
My primary obstacle in this case is the hardware interface. I imagine I would need to look up how sites like OMSI allow users to control the motors that move their webcam, or other online control of hardware.
What should my search terms be, or do you know of any libraries for python to read and write to external (adafruit-style) sensors?
Thanks!
Anthony
(https://i.stack.imgur./RzWIl.png)
"Raspberry pi python gpio" "Raspberry pi python i2c" "Raspberry pi python spi"
I am trying to send some data between 2 raspberry pi's over wifi without them being connected to a network.
I want it to work similar to the way beacons and probe requests work, where a broadcast can be sent out the wireless interface.
the data I want to send will be the hostname of the device and the time the packet was sent.
I've been trying to figure this out for the last few days but I cannot get anything to work without them being on the same network.
Is anybody able to point me in the right direction?
I'm not too fussed about what language I use. I have been trying python and C with little success.
Note: This is not really an answer, just some ideas to research, so feel free to edit or comment with corrections.
There are 6 modes a wifi adapter can operate in. From wikipedia:
Master (acting as an access point), Managed (client, also known as station), Ad hoc, Mesh, Repeater, and Monitor mode.
But I believe not all wifi adapters support all modes, so make sure you have suitable hardware.
I would suggest adhoc or mesh would be the most suitable to your purpose. With adhoc mode at least the devices would need to be configured beforehand to use the same SSID and channel. This may not apply to mesh mode.
A quick search yields a few links in regards to using Raspberry Pis in a mesh network:
http://hackaday.com/2012/11/14/mesh-networking-with-multiple-raspberry-pi-boards/
Wireless mesh networking on Raspberry Pi using batman-adv protocol
http://www.netlore.co.uk/airmesh/?page=about
I would also look at using the Dot11* family of packets in the excellent Python Scapy library (not to be confused with Scrapy). You should be able to craft custom packets and transmit them if the interface is in the right mode. Here's a project that creates fake access points that probably contains good info: https://github.com/rpp0/scapy-fakeap