multicast messages

If doesn't fit into any other category ....
Monki
Posts: 42
Joined: Mon Feb 27, 2023 12:56 pm
Location: Berlin
Has thanked: 6 times
Been thanked: 6 times

multicast messages

Post by Monki »

Hello FRANCESCO,
one question is, is there the possibility of receiving multicast messages in the Annex or is it easy to implement

monki
User avatar
cicciocb
Site Admin
Posts: 2063
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 439 times
Been thanked: 1361 times
Contact:

Re: multicast messages

Post by cicciocb »

UDP multicast?
Monki
Posts: 42
Joined: Mon Feb 27, 2023 12:56 pm
Location: Berlin
Has thanked: 6 times
Been thanked: 6 times

Re: multicast messages

Post by Monki »

Yes
Monki
Posts: 42
Joined: Mon Feb 27, 2023 12:56 pm
Location: Berlin
Has thanked: 6 times
Been thanked: 6 times

Re: multicast messages

Post by Monki »

Yes
User avatar
cicciocb
Site Admin
Posts: 2063
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 439 times
Been thanked: 1361 times
Contact:

Re: multicast messages

Post by cicciocb »

yes, I think it should work.
Monki
Posts: 42
Joined: Mon Feb 27, 2023 12:56 pm
Location: Berlin
Has thanked: 6 times
Been thanked: 6 times

Re: multicast messages

Post by Monki »

Hi Francesco,
I tried it with
udp.begin 5353
onudp udpreceive
wait
udpreceive:
v$ = udp.read$ data
vlog v$
return
But I don't get any message. With b4X (another basic variant) it works
User avatar
cicciocb
Site Admin
Posts: 2063
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 439 times
Been thanked: 1361 times
Contact:

Re: multicast messages

Post by cicciocb »

I just tried with an esp32-s3 with the toolkit and using the address .255 I receive the messages
image.png
image.png
You do not have the required permissions to view the files attached to this post.
Monki
Posts: 42
Joined: Mon Feb 27, 2023 12:56 pm
Location: Berlin
Has thanked: 6 times
Been thanked: 6 times

Re: multicast messages

Post by Monki »

hello Francesco,
Thanks for your effort, but I think you confused multicast with broadcast, I have a link here https://book.hacktricks.xyz/network-ser ... t-dns-mdns
found in which the functionality is explained
User avatar
cicciocb
Site Admin
Posts: 2063
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 439 times
Been thanked: 1361 times
Contact:

Re: multicast messages

Post by cicciocb »

Yes you are right, I confused multicast with broadcast but you confused UDP with DNS :lol:

Yes, I implemented it in the version 1.51.1 but I removed it in the following version replacing it with NETBIOS
image.png
You do not have the required permissions to view the files attached to this post.
Monki
Posts: 42
Joined: Mon Feb 27, 2023 12:56 pm
Location: Berlin
Has thanked: 6 times
Been thanked: 6 times

Re: multicast messages

Post by Monki »

Good morning Francesco

I have several smart home devices (shelly rgbw2), these send their status via Udp to the multicast address 224.01.1.187 port 5683.
As mentioned above, I created an app for this purpose with B4X, which also works well.
b4x is a basic language that then compiles the code into native bytecode. Here is an excerpt of the Java inline code, perhaps it will be more understandable


Sub CreateMulticastSocket(EventName As String, Port As Int, Group As String)
Dim multi As JavaObject
multi.InitializeNewInstance("java.net.MulticastSocket", Array(Port))
Dim inet As JavaObject
multi.RunMethod("joinGroup", Array(inet.InitializeStatic("java.net.InetAddress").RunMethod("getByName", Array(Group))))
Dim jo As JavaObject = Me
jo.RunMethod("SetMulticastSocket", Array(EventName, multi, udp))
End sub

#if java
import java.net.*;
public void SetMulticastSocket(String EventName, MulticastSocket socket, anywheresoftware.b4a.objects.SocketWrapper.UDPSocket udp) {
udp.init(getBA(), EventName, 8192, socket);
}
#end if
Post Reply