espconn_igmp_join and espconn_sendto

AgentSmithers
Posts: 123
Joined: Sat Apr 01, 2017 1:21 am
Contact:

espconn_igmp_join and espconn_sendto

Postby AgentSmithers » Tue May 29, 2018 11:51 am

Hi everyone,
Does anyone know what is required to send packets after IGMP_Join
It seems after going and joining a IGMP group packets no long send via UDP.
With the example below, the first packet always gets sent out but not the 2nd.
Thanks in advanced!!

Code: Select all

static int ICACHE_FLASH_ATTR igmp_join(uint32_t ip) {
   if( ip )
   {
      ip_addr_t ipgroup;
      int ret;
      ipaddr_aton(MULTICAST_ADDR, & ipgroup);
      os_printf("IGMP Joining: %08x %08x, " , ip, ipgroup.addr);
      espconn_sendto(&HTTPUDPptrespconn, UDPResponse, os_strlen(UDPResponse)); //Send Back Answer   
      ret = espconn_igmp_join( (ip_addr_t *) & ip, & ipgroup); //At this point SendTo stops
      espconn_sendto(&HTTPUDPptrespconn, UDPResponse, os_strlen(UDPResponse)); //Send Back Answer   
      if (ret != 0)
      {
         os_printf( " failed, code %d\n " , ret);
      } else {
         os_printf( " joined\n " );
      }
      return 0;
   }
   os_printf( " Failed to obtain current IP\n " );
   return 1;
}

AgentSmithers
Posts: 123
Joined: Sat Apr 01, 2017 1:21 am
Contact:

Re: espconn_igmp_join and espconn_sendto

Postby AgentSmithers » Mon Jun 04, 2018 8:57 am

Anyone from Espressif have any opinion?

AgentSmithers
Posts: 123
Joined: Sat Apr 01, 2017 1:21 am
Contact:

Re: espconn_igmp_join and espconn_sendto

Postby AgentSmithers » Mon Jun 04, 2018 11:24 am

I found the issue, Right when IGMP is switched on the RECV'ing of the IGMP pacjet updated the REMOTE_PORT and IP information.

I used the following code below to backup and restore and IP/PORT information to prevent losing where to send the Multicast Data, in this case, 239.255.255.250

Code: Select all

if (espconn_get_connection_info(udpconn,&premot,0) == ESPCONN_OK)
   {

      if(udpconn->link_cnt) {
         os_printf("EspConn %u HTTPUDP connections:\r\n", udpconn->link_cnt);
         int   i = 0;
         while(i < udpconn->link_cnt) {
            os_printf("%d) " IPSTR ":%u %s\r\n", i,  IP2STR(premot[i].remote_ip), premot[i].remote_port, msg_espconn_state[premot[i].state] );
            i++;
         };
      }

      //os_printf("Received device find message\n\r");
      //os_sprintf(DeviceBuffer, "%s" MACSTR " " IPSTR, pusrdata, MAC2STR(hwaddr), IP2STR(&ipconfig.ip));
      //os_printf("%s\n", DeviceBuffer);

      remot_info premotbackup;
      premotbackup.remote_port  = udpconn->proto.udp->remote_port;
      premotbackup.remote_ip[0] = udpconn->proto.udp->remote_ip[0];
      premotbackup.remote_ip[1] = udpconn->proto.udp->remote_ip[1];
      premotbackup.remote_ip[2] = udpconn->proto.udp->remote_ip[2];
      premotbackup.remote_ip[3] = udpconn->proto.udp->remote_ip[3];

      unsigned short strlength = os_strlen(DeviceBuffer);
      udpconn->proto.udp->remote_port = premot->remote_port;
      udpconn->proto.udp->remote_ip[0] = premot->remote_ip[0];
      udpconn->proto.udp->remote_ip[1] = premot->remote_ip[1];
      udpconn->proto.udp->remote_ip[2] = premot->remote_ip[2];
      udpconn->proto.udp->remote_ip[3] = premot->remote_ip[3];

      espconn_sendto(udpconn, SSDPResponse, os_strlen(SSDPResponse)); //Send Back Answer
 
      udpconn->proto.udp->remote_port  = premotbackup.remote_port;
      udpconn->proto.udp->remote_ip[0] = premotbackup.remote_ip[0];
      udpconn->proto.udp->remote_ip[1] = premotbackup.remote_ip[1];
      udpconn->proto.udp->remote_ip[2] = premotbackup.remote_ip[2];
      udpconn->proto.udp->remote_ip[3] = premotbackup.remote_ip[3];

      //os_printf("SSDPResponse sent: %s\n\r", SSDPResponse);
      //os_printf("SSDPResponse sent to %s\n\r", IP2STR(&premot->remote_ip));  //Cashes
   }

Who is online

Users browsing this forum: No registered users and 27 guests