wip_pingCreate

Hi all.
I want to use the wip_pingCreate in the developer studio, but I do not know how to do it correctly. Advice please.
my attempt:

PingRet=wip_pingCreate (“94.153.184.130”, WIP_CEV_PING, 0);
PingRet1=wip_pingCreateOpts(“94.153.184.130”,WIP_COPT_INTERVAL,60000);

Hi,

Please refer to the document “WIP_Open_AT_IP_Connectivity_Development_Guide.pdf”, for the API definitions, variables and structures related to Ping. Find below a code snippet on how to use the APIs for your reference.

#define PEERADDR “94.153.184.130”
static void evhandler ( wip_event_t *ev, void *ctx) 
{
  switch( ev->kind) 
 {

  case WIP_CEV_OPEN:  
  {
    break;
  }
  case WIP_CEV_ERROR: 
  {
    wip_close( ev->channel);
    break;
  }
  case WIP_CEV_PEER_CLOSE: 
  {
    wip_close( ev->channel);
    break;
  }
  case WIP_CEV_PING: 
  {
    wip_debug( "PING");
    break;
  }
}
void appli_entry()
{
  wip_channel_t ping = wip_pingCreateOpts( PEERADDR, evhandler, NULL,
                                           WIP_COPT_INTERVAL, 5000,
                                           WIP_COPT_END);
}

How do I use the following code to request the response_time and timeout together with the WORKING PING CODE below?

struct wip_event_content_ping_t {     
      int    packet_idx;    /* Index of the paquet in the sent equence */
      u32    response_time; /* Time taken by the echo to come back, in ms. */
      bool   timeout;       /* Did the echo take too long to come bakc?
                             * if timeout is true, response_time is meaningless
                             * (and set to 0). */
    } ping;

WORKING PING CODE:

#define PEERADDR "8.8.8.8"

static void ping_evhandler ( wip_event_t *ev, void *ctx)
{
    switch ( ev->kind )
    {
		case WIP_CEV_DONE:
		{
			break;
		}
		case WIP_CEV_ERROR:
		{
			wip_close( ev->channel);
			break;
		}
		case WIP_CEV_OPEN:
		{
			break;
		}
		case WIP_CEV_PEER_CLOSE:
		{
			wip_close( ev->channel);
			break;
		}
		case WIP_CEV_PING:
		{
			debugmsg("\r\nPING\r\n");
			break;
		}
		case WIP_CEV_READ:
		{
			break;
		}
		case WIP_CEV_WRITE:
		{
			break;
		}
    }
}

void ping_now()
{
	wip_channel_t ping = wip_pingCreateOpts(PEERADDR, ping_evhandler, NULL,
                                           WIP_COPT_INTERVAL, 5000,
                                           WIP_COPT_END);

}

Hi,

Please find an example/snippet for the usage below:

ascii RspStr [ 70 ];

    switch(event->kind)
    {
       case WIP_CEV_PING: 
      {
            wip_debug( "PING");
            wm_sprintf ( RspStr, "\r\n PING: %d,%d,%d\r\n",
                     event->content.ping.timeout,
                     event->content.ping.packet_idx,
                     event->content.ping.response_time
                   );
        adl_atSendResponsePort( ADL_AT_RSP, Port, RspStr );    
      }
      break;
   }

Regards,
Rex

Thank you Rex, you’re a star!

:slight_smile: