Recieve MQTT, Send TCP-String - tcp

so what I want to do is the following:
Using a Raspberry Pi to recieve MQTT-Strings, read them and then send a completely
different string to an audio-player depending on the message.
So for example:
MQTT string contains info that 3 people stand in x 15, y 15 coordinates,
which means "preset 3" should be triggered.
To trigger "play p3" needs to be sent to the player on a certain IP.
Is there any strong way to do this in python without performance issues?
I tought about using mosquito and just constantly checking in a loop with different if's...
Thanks for the input in advance!

Related

Esp32 micropython webserver TCP socket to check http get request

Good afternoon everyone,
For a school project I will make a RC car using a c8051 microcontroller and to send the uart data to it I'm using a ESP32 so that I can display a webpage so that the user choose the direction of the car. I've spent a lot of time on micropython doc's page and tutorial for TCP sockets and I see in every one of them that to check if the webpage was requested they use something like:
If(request==6):
And I can't figure out why 6, what that represents??
I appreciate any help given.
The answer found in the comment section of the link given
"In the while loop, after receiving a request, we need to check if the request contains the ‘/?led=on’ or ‘/?led=on’ expressions. For that, we can apply the find() method on the request variable. the find() method returns the lowest index of the substring we are looking for.
Because the substrings we are looking for are always on index 6, we can add an if statement to detect the content of the request. If the led_on variable is equal to 6, we know we’ve received a request on the /?led=on URL and we turn the LED on.
If the led_off variable is equal to 6, we’ve received a request on the /?led=off URL and we turn the LED off."

Zigbee communication among 3 devices is carrying garbage along with the actual data transmitted

I am broadcasting Hello using one Xbee (say A).....Xbee (say B) and Xbee (say C) are receiving a lot of garbage values before and after Hello.
All the baudrates are 9600...where am I going wrong?
It would help if you posted an example of the data you see, perhaps the hex values of each byte.
My guess is that you've configured the modules for "API mode" which wraps payloads with a header (starting with 0x7E, the character ~) and footer. It's useful for "smart" devices because it supports multiple packet types.
Check your settings, and make sure you're using ATAP=0. You can use XCTU to change the settings, or from a terminal use the escape sequence (1 second pause, +++, 1 second pause then module should respond with OK) to enter command mode. In command mode, first set ATAP0 and then ATWR to save the changes.

How to know if you missed an incoming call in AT commands

I am using Putty to simulate my phone's modem connected via serial. When my phone receives a call it outputs 'RING' into putty but when the caller cancel the call Putty doesn't out put any response or result.
How would the modem know that the caller disconnect/cancelled the call, but not output it in putty?
Thanks
To detect missed calls you can try three things.
Check if there is a suitable AT+CIND indicator you can turn on. I do not think call will do since I assume it only goes to 1 when the call is answered. If your phone supports callsetup or something similar that should be what you need (you will have to implement logic to detect when a call does not go to state active).
For an example of enabling AT+CIND indicators, see chapter "8.57 Informative examples" in 27.007 for more explanation, and pay close attention to The subparameter order in the command is defined by the query command order, e.g.
if AT+CIND=? returns
+CIND: ("abc",(0-1)),("xyz",(0,1)),("call",(0,1))
then call is index 3, and for
+CIND: ("abc",(0-1)),("call",(0,1)),("xyz",(0,1))
call is index 2. Do not hard code any assumptions here, this should be parsed and checked run-time (one check at the beginning is enough).
Alternatively you can upon RING start polling call status with AT+CLCC until the call is no longer listed.
Or you could poll the MC phonebook storage and detect changes.
Most modems show the incoming phone number and a RING when a call is received and an END when the call is cancelled. To view the missed calls, you may use the following AT Commands.
AT+CPBS="MC"
AT+CPBR=1,99
First command tells the modem to look in the missed call phone book and the second command loads entries from 1 to 99. Note that this behavior is not standard. I was able to replicate this on a GSM module but not on my 3G modem. Try it on your modem and check if this works. All the best.

AT command for disable Radio Signal Strength Indication and alike?

Im working on a program to send and recieve SMS using a GSM modem and my computer.
I have gotten sending and receiving to work - well sort of.
Once in a while my program is sent into a total chrash due to modem is mixing up information about Radio Signal Strength Indication and alike, while also serving my program with the hex code for the message.
My code can handle the hex code just fine. but I have seen the following line popup while im decoding a byte stream:
^RSSI: 2
So far I've seen it send out values between 1 and 10.
Is there an AT Command that can disable them? I have no need for them.
Or alternative: Is there a general syntax for them, so I can filter them out before decoding?
Im leaning towards a filter solution. But that would be more easy to implement if I knew whenever modem is sending out on the form: "^SOMETHING: xxx", then It would be nice to know if it is always followed up be a delimiter say for instance "\r".
You should try turning off periodic messages as using AT^CURC=0.
Information regarding the AT^CURC command:
AT^CURC? Current setting of periodic status messages
AT^CURC=? See what you possible values are
AT^CURC=0 turn off periodic status messages
The best way to tackle this scenario would be to replace that part of the response with an empty string because otherwise, it will be difficult to check even if the command sent to disable it is working or not.
This regex will match all those. You can replace them ideally by an empty string.
(\\n|\\r|\\r\\n)\\^.*(\\n|\\r|\\r\\n)

Communication between two nodes

I have an assignment to implementation of communication between 2 PC terminals using Ethernet.
There is no big deal in establishing network between 2 nodes. but the the big deal is "8 bit data sent on one node is to be decoded on the other node & the same is to be displayed & if possible though a front end window."
the specs for the front end window on the receiving node is as follows , say for example 10110101 is sent from node 1 , the same is to be decoded & interpreted as below using a frontend GUI window , A-On
B-off
C-On
D-On
E-Off
F-On
G-Off
H-On
So please someone suggest me is any other application available to see the decoding process on terminal or what are the steps i need to intiate.
All your suggestions are appreciated,
Thanks in advance,
I guess your specific solution depends on if you are allowed to use existing libraries. Either way I would checkout networkComms.net, an open source network library written in C#.
You could achieve your basic goal if you modify the basic send example (11 lines of code) here. Instead of sending a random string, send your 8 bits, and on the receiving end, rather than just writing the string to the console do something cleverer:
if (recievedString == "10110101")
{
//Do this
}
else
{
//Do this instead
}
If you are not allowed to use existing libraries and have to write something from scatch perhaps networkComms.net could act as a good guide?

Resources