I am currently developing a BLE communication system where an app on the phone will communicate with a peripheral device. I am working on both the BLE client on the phone and the BLE server on the peripheral
For the app part, I'm using react-native-ble-manager and for the ble server part, I based it on examples from the official BLE docs using dbus and Python.
I want to add some security to the pairing process, by implementing the PIN security mechanism or just saving the same private key and verifying the connection is trustworthy but after spending some time researching how this should be implemented I did not find any good examples. Where could I find some resources or guidelines on how to implement these security mechanisms?
Related
I have two python scripts which need to get data from the same modbus server.
However they cannot be simultaneously connected to the same modbus server, so I am looking for a "proxy" software.
This proxy will then sequentially transfer the modbus queries to the modbus server.
Solution should run on debian 11 lite.
Thanks!
I have the same challenges before and ended up with Modbus-to-MQTT bridge solution, because each protocol has its limit, Modbus is designed for master-slave poll in nature and MQTT is good for multiple clients/subscribers.
Modbus + MQTT, such a combination is just nice and could be very powerful in modern IoT applications. You can try modpoll, which is a python-based Modbus tool and can run as a Modbus-to-MQTT bridge in your case.
Assuming you are dealing with Modbus TCP you can try modbus-proxy:
Many modbus devices support only one or very few clients. This proxy
acts as a bridge between the client and the modbus device. It can be
seen as a layer 7 reverse proxy. This allows multiple clients to
communicate with the same modbus device.
When multiple clients are connected, cross messages are avoided by
serializing communication on a first come first served REQ/REP basis.
EDIT: According to your comment below:
...it is RTU over a linux file descriptor /dev/ttyS1
That seems to me a not-so-straightforward way of saying that you are dealing with a serial link.
If that's the case I'm afraid you need to go back all the way to the physical layer.
If you have a point-to-point serial connection (no matter the voltage levels you have, they can be TTL 3.3VDC or RS-232) there is no way you can have more than one Modbus client connecting to the same server.
For a serial link to have more than two devices (two or multiple clients sending queries to a Modbus server, for instance) you need a way for the devices to take control of the bus when they communicate and let go of it when they are idle. An RS-485 multipoint serial link is the most frequent solution to this problem.
If you follow the link you will find many resources and documentation. That might be a bit overwhelming but it is actually very easy: instead of connecting RX to TX as you'd do for a normal serial port you will have two cables for each device (they are called A and B or D+ and D-) that you can put together. And you only need to add a TTL to RS-485 transceiver in between each device and the bus (or RS-232 to RS-485, depending on your devices).
There are a couple of nuances:
You might need terminating resistors, but that should only be the case if your devices are far away (more than several meters) from each other.
If you go for the cheapest transceivers you might end up being forced to toggle the bus in your software, which is not a good solution. See my answer here for more details. And better aim for something with automatic TX enable.
The most complete reference on all these topics I know of is Jan Axelson's book Serial Port Complete. It's a bit old (the last edition was released in 2007) but still very relevant. And you can find older editions secondhand for next to nothing. If you need to work with serial ports, this book will be a very valuable companion.
Final note: if you are not able or willing to mess with the phy layer, you might, of course, find other solutions that are more palatable. You might, for instance, implement a software forwarder to take queries from your clients and convert them to Modbus RTU to be sent to your server. Pymodbus includes an example, but since you did not elaborate much I'm not sure it will be useful for your situation.
newbie here.
I work in a factory that produce electric cables.
I'm trying to build a web application that will handle production processes. For this i need some real time data. There are multiple types of machines , some of them are older and uses a lot of digital counters like this on: https://mirror2.mixtronica.com/42248-superlarge_default/h7cx-aud1-n-contador-omron.jpg . Some of them are newer and have plc's ( siemens s7-1200 , s7-1500 and others ).
I have 0 experience with plc and plc programming. From what I saw from my research is that newer plc like s7 have a option "WEB SERVER", if that's enables i may be able to send data from counters and other stuff to a web page that is automated generated from that option. Folks on the internet uses software like Tia Portal to connect to them. My question is : if i try to connected at them with TIA-PORTAL and ethernet cable is there any possibility that i will corrupt something ? Tia-portal will recognize the program that's running (it was not uplouded by me ) ?
Is there any way that i can make that digital counters transmit data on a raspberry pi or similar device. If not , what are my options there , is there any product intergrated with iot that i can use ?
I also have some industrial scales but those have rs 232 interface and that was prrety smooth to make them talk with my pi.
From what I understand you want to read and send data to the machines, correct? Because there are some simpler approaches than having to build an IoT application from scratch.
Recently I've been studying solutions like this and the best alternative I've looked at is using Thingsboard (which can be installed locally or using the remote platform) or other platforms like Losant... This avoids creating a lot from scratch (storing data, create charts...), however, in a way, is limited in a few things and a gateway may be needed to handle the conversion of data from devices to platform. I'm still learning how to use it, but I think it's worth leaving it as a tip if your case is more about collecting and dislay data or creating simple actions or logic.
About connecting the devices:
For machines with PLC I recommend that you research OPC-UA or MQTT, they are protocols that will facilitate communication and it seems that these versions of the Siemens S7 have OPC-UA.
For machines without PLC and without any communication port you may be forced to install a "gateway", an Arduino, ESP32 or another Raspberry PI may facilitate things, or even a small PLC, to collect the discrete data and convert them to Modbus, MQTT, OPC-UA, or another way that you can send it to your server... The concern here would be with electromagnetic interference, but that will depend on your equipment (with industrial equipment validated as a PLC you won't have these problems).
This is not a complete answer, but I believe it will help you to develop the solution :)
Actually i can send data from pyhton(pyserial) to arduino through cable,but i want to do that with hm-10, normally bluetooth module which is the hc-05 ,hc-06 u can find port,
With wire or wirelles(hc-05) com7 port:
arduino = serial.Serial("COM7", baudrate=9600,timeout=.1)"
But hm-10 is ble.
what i need to write instead of com7?
or how can i solve that problem?
(windows 10)
The pySerial library will not work with the HM-10 module because the module uses Bluetooth Low Energy (rather than Bluetooth Classic).
This means you will have to create a GATT Client to interact with a BLE GATT Server. Typically you would have the Arduino in the Peripheral role (server) and the Windows PC in the Central role (Client).
A quick internet search suggests that the GATT service on HM-10 module has the following values:
Service UUID: 0000FFE0-0000-1000-8000-00805F9B34FB
Characteristic UUID: 0000FFE1-0000-1000-8000-00805F9B34FB
You can check this using a generic Bluetooth Low Energy scanning and exploration tool such as nRF Connect
There are a limited number of Python BLE Central libraries with Bleak probably being the pick of the bunch and has good examples of how to use it.
I'm on a team working on a non-profit, open-source project and we're creating a web-based configuration tool to control a piece of custom hardware on a Raspberry Pi, using the "Web Bluetooth API".
Packets over the BLE connection are limited to 512 bytes, so we seem to need a transfer protocol layer to assist communication with the Pi.
We do not want a UART implementation, as we want transmission guarantees.
Does such a transfer protocol layer exist, ideally implemented in Python?
Or is there a simple way to generate a python implementation of a transfer protocol layer, that would work with 512byte packages?
Your question is a little too broad to be able to give any kind of specifics.
The official profiles that are available with Bluetooth are documented at: https://www.bluetooth.com/specifications/specs/
Custom services can be created fairly easily if you have control over both ends of the Bluetooth link. The Nordic UART Service is one that appears to be quite common and there are various apps around that understand it to make testing of your peripheral easier.
Creating a custom service that minimises the amount of data sent over the Bluetooth link is usually the goal. There are various guides around that can help.
One of the better guides for creating a Bluetooth Peripheral with BlueZ and Python, is this one https://punchthrough.com/creating-a-ble-peripheral-with-bluez/
There are also Python examples in the BlueZ source tree
And for completeness the BlueZ API's are documented at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc
I am trying to connect to an existing network of devices communicating via RS485 (HMI + PLC, the communication protocol is Fatek's own protocol). I have no problem connecting directly to the PLC (I can read and write registers), but I have to leave the HMI<>PLC connection. When connecting directly to the line between HMI and PLC (via an FTDI USB<>RS485 adapter) I can't read or write registers from the PLC (I don't receive proper responses).
From I've gathered, it's possible to connect multiple devices on one RS485 line, provided they have their addresses set. And here's the problem: I can't see where to set this address. Is it included in every "frame" sent? Is it set somewhere in the driver of the USB<>RS485 adapter? Is it hardcoded in the adapter?
Thank you in advance,
MichaĆ
Usually in serial communications, either 1:1 or 1:N, there can only be one master (in your case the HMI is the master) and one or more slaves that respond to requests from the master, and the master must always wait to receive the response before submitting a new request.
If you connect a second master you are creating collisions on the network, RS-485 has no way to manage those collisions.
Only one master can exist on the serial network.
If you want to overcome these limitations think about replacing that network with Ethernet and TCP/IP
As the Wikipedia article below, RS485 is an electrical specification with no default software or protocol.
The mechanism for handling the device address must be created by yourself or by selecting a protocol having such a function and applying it.
RS-485 - Wikipedia
RS-485 only specifies electrical characteristics of the generator and the receiver: the physical layer. It does not specify or recommend any communications protocol; Other standards define the protocols for communication over an RS-485 link. The foreword to the standard references The Telecommunications Systems Bulletin TSB-89 which contains application guidelines, including data signaling rate vs. cable length, stub length, and configurations.
For example, isn't Modbus often used?
Modbus -Wikipedia
Modbus is a data communications protocol originally published by Modicon (now Schneider Electric) in 1979 for use with its programmable logic controllers (PLCs). Modbus has become a de facto standard communication protocol and is now a commonly available means of connecting industrial electronic devices. Modbus is popular in industrial environments because it is openly published and royalty-free.
There are also some python packages.
minimalmodbus 1.0.2
pymodbus 2.3.0
How to set the device address will need to be done according to the specifications of the package to be adopted.
In Addition:
By the way, if you are using a manufacturer's proprietary protocol for a PLC device, it is likely that you will be using such multi-drop for that device and protocol.
It seems that the first way to do this is to contact the manufacturer's support desk.
Or even if this site is a manufacturer support location, you will need to add information such as what equipment you are trying to connect and in what configuration.
HMI_Support & PLC_Support
HMI_Products & PLC_Products
It looks like your system is using "Fatek communication protocol" which is documented in Appendix 1 of the FB user manual. (Download here)
That protocol looks like many such protocols typical of industrial PLC controllers. However, it is a bit complicated by the number of message types. Without looking too deeply, it seems practical to implement the logic in a few days. Or there is likely an open source implementation somewhere (though I didn't search).