Sony API discovery process and the Sony STR-DN1080 - sony-audio-control-api

re: https://developer.sony.com/develop/audio-control-api/hardware-overview/discovery-process
Hello. I have an APAC region Sony STR-DN1080 AVR. I am able to control said AVR via the API just fine. I just cannot discover supported Sony devices using SSDP.
It seems that the AVR is periodically advertising itself to the network via UDP, but it is not responding to any multicast requests using the format described in the docs.
The Web API service does not even reply when I replace the "ST: ...." line with ST: upnp:rootdevice or ST: ssdp:all. Other devices on my network do reply, but not the Web API service. The built-in UPnP/DLNA service does respond however.
Here is my packet:
String msg = "M-SEARCH * HTTP/1.1\r\n" +
"HOST: 239.255.255.250:1900\r\n" +
"MAN: \"ssdp:discover\"\r\n" +
"MX: 1\r\n" +
"ST: urn:schemas-sony-com:service:ScalarWebAPI:1\r\n" +
"USER-AGENT: me\r\n" +
"\r\n" ;
Is there something I am missing? Thanks in advance.

Solution. I couldn't get the required response from the Sony STR-DN1080 with the specified M-SEARCH broadcast no matter how I tried. So instead, this is what I did:
use the tag ST: ssdp:all\r\n in the M-SEARCH broadcast.
String msg = "M-SEARCH * HTTP/1.1\r\n" +
"HOST: 239.255.255.250:1900\r\n" +
"MAN: \"ssdp:discover\"\r\n" +
"MX: 1\r\n" +
"ST: ssdp:all\r\n" +
"\r\n" ;
build a Set of the IP addresses of all replying devices.
search each device in Set for the existence of this file: {ip address}:8008/ssdp/device-desc.xml.
scan through each line of that XML file for string "STR-DN1080".
It's not where I wanted to end up, but it works.

Related

Send data without "MBAP Header" in Qt Modbus

I am sending data from TCP to RS485 serial port using the following scheme:
computer <--> TCP/RS485 adapter <--> RS485 relay
source code:
QVector<quint16> vdata(4);
...
QModbusDataUnit adu(QModbusDataUnit::Coils, deviceAddress, vdata);
...
auto *reply = modbusDevice->sendReadRequest(adu, deviceAddress);
sended data:
qt.modbus.lowlevel: (TCP client) Sent TCP ADU: "00000000000801050010ff008dff"
qt.modbus: (TCP client) Sent TCP PDU: 0x050010ff008dff with tId: 0
Since the relay works on RS485, the data "1050010ff008dff" should go to it.
How can I send only "1050010ff008dff" instead of "00000000000801050010ff008dff" using Qt Modbus?
Devices can exchange data via QTcpSocket:
QString d = "01050010ff008dff";
QByteArray b = makeRTUFrame(1, ui->sboxFunc->value(), QByteArray::fromHex(d.toLatin1()));
tcpClient.write( b );
But the program needs to communicate in Qt Modbus.
I searched for a solution on google search engine and stackoverflow. None of the provided answers helped solve this problem.
Any support appreciated.
Thanks in advance.

How establish connection between ESP32 as access point and local server

I have to send a file to the local server so I use the httpClient and try to use the post with the host: http://127.0.0.1:5000/show-version, In the serial monitor, but it doesn't work, again the ESP is in access point mode
void SendVersion (){
client.begin(HOST);
client.addHeader("Content-Type", "text/plain");
int response = client.POST(version);
if(response>0){
String response = client.getString(); //Get the response to the request
Serial.println(response); //Print return code
Serial.println(response); //Print request answer
}else{
Serial.print("Error on sending POST: ");
Serial.println(response);
}
client.end();
}
127.0.0.1 is a special IP address which means "this computer or device". When you use it on the ESP32 it means the ESP32, not the server you're trying to connect to. It's also known as localhost - again, shorthand for the computer or device the software is running on. It does not identify an external computer.
You need to use the actual IP address of the server you're trying to connect to. How you'll find that depends on the OS the server is running - if you don't know how to do it, use Google to find out.
And of course, if the ESP32 is in AP mode then the server it's trying to talk to needs to be connected to the ESP32's wifi network in order for the ESP32 to be able to talk to it.

Sending data to MyMqttHub through AT Commands

I've been coding a AT client using ESP32 S2 as a host and Nimbelink's Skywire Nano (nrf9160) as a LTE Modem controlled by Serial AT Commands, the LTE module is responsive and is working well. The LTE modem has an internal TCP Stack, which we have used to send data to dweet.io through a HTTP POST with success, but we haven't been successful in doing the same sending data to a private MQTT server.
The LTE module uses a method called Socket Dials, these are AT commands that facilitate sending data to the web, it basically consist in these three commands:
AT#SOCKET to activate the socket
AT#TCPCONN to connect to an URL
Example:
at#xtcpconn=3,"node02.myqtthub.com",1883
AT#TCPSEND which opens a > promt in which you enter whatever you are going to send
I'm not a communication protocols expert, so it has been a bit difficult finding the correct way to send the string since I haven't found similar examples using TCP sockets. I have tried sending mosquitto_pub strings withouy success and nimbelink only has an example using HTTP, I hope some one can help me with this or at least send me in the right direction.
at#xsocket=3,1,1
#XSOCKET: 3,6
OK
at#xtcpconn=3,"node02.myqtthub.com",1883
#XTCPCONN: 1
OK
at#xtcpsend=3
mosquitto_pub -h node02.myqtthub.com -i hub -u user -P 'password' -t topic -m "hello world"#XTCPSEND: 104
OK
SOCK: 3,HUP
Edit: added the LTE log of the attempt

How to send and receive sms while using GPRS in QUECTEL modem M95?

I am using QUECTEL M95 modem to connect the server using gprs . And the modem has facility to send and receive test messages .In my project both the situation occurs . By default in programming ip address been set, but there are chances for updating the ip address by sms . Wheather it is possible to send sms during gprs mode? If possible how ? Please suggest me how to do.
Yes, you can do it. If you are using Transparent mode (AT+QIMODE=1) you need to switch to Normal mode (AT+QIMODE=0) and you can send SMS using AT+CMGS regardless of active gprs connection.
You have to use the normal command mode (not to switch to transparent mode).
AT+QINDI=1 - to receive data with poll command
AT+QIRD - poll received data
AT+QISEND - send data
AT+CMGS - send SMS
AT+CMGL="REC UNREAD" - poll new messages

Fetch source address and port number of packet - Scapy script

I am doing a sniffing of the network and trying to get ip address and port number on every tcp packet.
I used scapy with python and could successfully sniff packets and in a callback function could even print the packet summary. But I would want to do more, like fetching only the IP address of the source and its port number. How can i accomplish it? Below is my code:
#!/usr/bin/evn python
from scapy.all.import.*
def print_summary(pkt):
packet = pkt.summary()
print packet
sniff(filter="tcp",prn=packet_summary)
Please suggest a method to print only the source IP address of every packet.
Thanks.
It is not very difficult. Try the following code:
#!/usr/bin/env python
from scapy.all import *
def print_summary(pkt):
if IP in pkt:
ip_src=pkt[IP].src
ip_dst=pkt[IP].dst
if TCP in pkt:
tcp_sport=pkt[TCP].sport
tcp_dport=pkt[TCP].dport
print " IP src " + str(ip_src) + " TCP sport " + str(tcp_sport)
print " IP dst " + str(ip_dst) + " TCP dport " + str(tcp_dport)
# you can filter with something like that
if ( ( pkt[IP].src == "192.168.0.1") or ( pkt[IP].dst == "192.168.0.1") ):
print("!")
sniff(filter="ip",prn=print_summary)
# or it possible to filter with filter parameter...!
sniff(filter="ip and host 192.168.0.1",prn=print_summary)
Enjoy!
User2871462 has a terrific answer, I would comment on it but I don't have the required amount of reputation. :) The only thing I would add is that depending on the use case you may want to add the store=0 flag to the sniff call so you're not storing the packets. From the scapy docstring "store: wether to store sniffed packets or discard them".
sniff(filter="ip",prn=print_summary, store=0)

Resources