B4J Question Amazon Echo Discovery

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

I have an Amazon Echo Dot and trying to create a mini bridge using B4J.

Based on my research I should be able to listen on UDP port 1900 and when the Amazon Echo does a network discovery it should send a UDP message to the UDP port 1900.

I have used the following code, and when I run it, it seem to log 'Hello from RaspBerry' so I know the UDP message should come through.

Below is the code I am using:

B4X:
'Non-UI application (console / server application)
#Region Project Attributes
    #CommandLineArgs:
    #MergeLibraries: True
#End Region

Sub Process_Globals
    Dim UDPSocket1 As UDPSocket
End Sub

Sub AppStart (Args() As String)
    UDPSocket1.Initialize("UDP", 1900, 8000)
    Dim Packet As UDPPacket
    Dim data() As Byte
    data = "Hello from RaspBerry".GetBytes("UTF8")
    Packet.Initialize(data, "192.168.0.99", 1900)
    UDPSocket1.Send(Packet)
  
    StartMessageLoop
End Sub

Sub UDP_PacketArrived (Packet As UDPPacket)
    Dim msg As String
    msg = BytesToString(Packet.Data, Packet.Offset, Packet.Length, "UTF8")
    Log("Message received: " & msg)
End Sub

I found the following:
https://github.com/armzilla/amazon-...n/java/com/armzilla/ha/upnp/UpnpListener.java

Based on my code above, should this work based on the above link ?

I have tired but it doesn't seem to send any messages to my B4J during the discovery.

I am guessing after I get the UDP message I need to send the message back to UDP IP 239.255.255.250 ?
 
Last edited:
Top