Firstly, is multicast receiving functional on the DISCO-H747I board? If so, can someone point me to my error? I have the following function:
void rn_event_listener()
{
SocketAddress mcAddr;
const int MCAST_PORT = 5353;
const char * MCAST_GROUP = “224.0.0.251”;
int res;
mcAddr.set_ip_address(MCAST_GROUP);
mcAddr.set_port(MCAST_PORT);
char rx_buf[256];
int rx_len;
printf("Initializing RN evt Listener...\n");
//loop until the network stack is initialized
while(_net->get_connection_status() != NSAPI_STATUS_GLOBAL_UP){
ThisThread::sleep_for(20ms);
}
printf("Network stack ready, continuing RN evt Listener Config\n");
UDPSocket rn_server;
res = rn_server.open(_net);
printf("open: %d\n", res);
res = rn_server.connect(mcAddr);
printf("bind: %d\n", res);
int mcResult = rn_server.join_multicast_group(mcAddr);
if ( mcResult!= 0) {
printf("Error joining the multicast group\n");
while (true) {}
}
SocketAddress client;
while(true){
memset(rx_buf,0x00,sizeof(rx_buf));
rx_len = rn_server.recvfrom(&client, rx_buf, 256);// recveFrom(addr, rx_buf, 256);
printf("\n RN EVENT(%s):%s\r\n\n",(char *)client.get_ip_address(), rx_buf);
}
}
if I change the address/port to something other than a multicast address, this will function as expected. I can send to multicast addresses. I am new to mbed studio so it is likely I am missing something.
That’s the thing. There’s no error here. The code makes it to the .recvfrom(…) function. It’s almost like multicast is being filtered by the mac but I haven’t worked out how to check for that.
It appears that the driver doesn’t enable reception of multicast packets, or I’m not initializing it properly. Who knows: I’ve only been testing out mbed os for a few days. Anyway, If I manually set the Receive All packets bit in the ETH_MACPFR register then multicast packets are fed up to the application. Surely this should be adjusted to allow only the multicast packets I am interested in, but for now I just wanted to show I could receive multicast.
I see that H7 emac driver ist rewritten and uses a _V2 implementation, which does not use this eth_conf.c. But why? By using a custom target the settings could be overwritten, how should the configuration set for H7? @jeromecoutant
for compatibilty, the emac init it should enable multicast by default. I will try to test it. Maybe this function can be called also after emac init, then the filtering could be controlled in the user code.