Android Question read UDP multicast data

iz1kbp

Member
Hello everyone, I apologize for my poor English. I'm using Google Translate.
I've seen a lot of discussion about this issue on the forum, but it's now closed, with instructions to open new posts if needed.
'm not a programming expert; I still usually work with VB6.
This is my problem. I need to monitor multicast data traffic (sACN - protocol for lighting applications) emitted by an application on the address 239.255.0.X ( x is variable).

If I operate in broadcast or unicast (2.0.0.x), I can read the data; if I operate in multicast (239.x.x.x) , I can't.
I many post, I read that I need to add the enablement to the manifest (done),
B4X:
AddPermission(android.permission.CHANGE_WIFI_MULTICAST_STATE)
and that I need the Jnetwork library, because the b4a one isn't suitable.
(ref to this old post > Android Question : how udp receive multicast packets)
Now the questions:
1. How do I download and add this library to b4a?
2. Do I need to add code to indicate the type of traffic, or is the code I use for broadcast reception already sufficient?
Now I use this simple code for test :
Sock initalize
B4X:
UDPSocket2.Initialize("UDP2", 5568, 128)'
Sock read
B4X:
Sub UDP2_PacketArrived(Packet2 As UDPPacket)
    Dim data() As Byte = Packet2.Data
    Dim msg As String ' stringa arrivata al socket da xaudio
    msg = BytesToString(Packet2.Data, Packet2.Offset, Packet2.Length, "ASCII")
I have the impression that something is missing in the code...
Thanks to anyone who can offer advice.
Mario
 
Last edited:

iz1kbp

Member
I don't know if is the correct way....but I've installed b4J and copied the Jnetwork libray to the extra library in b4a and now I can found the JNETWORK in the list.
I've re-read the post that I've indicated,but I don't know the follow steps... (B4a page?)
Is there some one can Help me to undestad the last step?
Thank's in adavance
Mario
 
Upvote 0

iz1kbp

Member
Ciao Erel, thank for the replay.
I've done like fron your suggest in other post I refer (Android Question : how udp receive multicast packets)
Link to old closed post

This first problem I've solved....but the second problem I'm unable to solve it.
I followed the old post and downloaded the sddpcap example.
Just to see if it worked, I compiled it, and it does indeed work.
The problem is that the example MONKI provided is a class.
I tried moving the various routines from the class module to the main module, but it gives me this error during compilation.
B4X:
src\b4a\example\main.java:2842: error: cannot find symbol
   udp.init(getBA(), EventName, 8192, socket);
            ^
  symbol:   method getBA()
  location: class main

I searched the forum for the meaning of this error, and it turns out it's because the command in question refers to a class.
Could you please help me fix this error so that the routine works in the main module?
I'm attaching my project... it's poorly written, but it works in unicast and broadcast, without the copied parts.
Thank you anyway for your patience
Mario
 

Attachments

  • xtc.zip
    21.2 KB · Views: 10
Upvote 0

iz1kbp

Member
Hi Erel, yes, this is the post that I've read and report in post post.
The error report that i've, is the same that is reported by Paul.
Using the program as CLASS all work fine, using the code in the MAIN page, without class in project, i've the same error report by Paul.

Cattura.JPG

Have you an idea how to solve this problem?
Thank you again
Mario
 
Upvote 0

iz1kbp

Member
thank you Erel, now it is ok.
this app is only a small tester to debug if sAcn/artnet trafic (protocols for stage lighting) are present or not in line.
I use it for about...1 minutes or less during the stage setup, near the node? if protocol is ok, the tester is swich off...no waste of time.
why is it a big waste of time?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

iz1kbp

Member
You're absolutely right...I'm still learning the various mechanisms of b4a.
I usually develop small apps for my own use.
I'll take a closer look at the link you posted. Thanks again, and sorry for my ignorance!
Mario
 
Upvote 0
Top