1.3.3.24 SYS_NET_Open Function

C

SYS_MODULE_OBJ SYS_NET_Open (SYS_NET_Config *cfg,
SYS_NET_CALLBACK Net_cb,
void *cookie)

Summary

Opens a new NET System Service instance.

Description

This function opens the instance of the NET System Service.

Parameters

cfg - Configuration for which the NET Socket needs to be opened Net_cb - Function pointer to the Callback to be called in case of an event cookie - Cookie passed as one of the params in the Callback which was registered by the user in SYS_NET_Open ##Returns

Returns: If successful, returns a valid handle to an object. Otherwise, it returns SYS_MODULE_OBJ_INVALID.

Example

SYS_NET_Config 	g_NetServCfg;
SYS_MODULE_OBJ 		g_NetServHandle;

memset(&g_NetServCfg, 0, sizeof(g_NetServCfg));
g_NetServCfg.mode = SYS_NET_MODE_CLIENT;
strcpy(g_NetServCfg.host_name, APP_HOST_NAME);
g_NetServCfg.port = APP_HOST_PORT;
g_NetServCfg.enable_tls = 0;
g_NetServCfg.ip_prot = SYS_NET_IP_PROT_UDP;
g_NetServHandle = SYS_NET_Open(&g_NetServCfg, NetServCallback, 0);
if (g_NetServHandle == SYS_MODULE_OBJ_INVALID)
{
    // Handle error
}

Remarks

This routine should be called everytime a user wants to open a new NET socket. Also, in case the user is opening a Client Socket, and the under lying network interface is Wifi in AP Mode, it is recommended that the call be made only after the STA running the server connects to the AP on the Wifi interface.