1.3.3.20 SYS_NET_CALLBACK Function

C

void SYS_NET_CALLBACK (uint32_t event, void *data, void* cookie)

Summary

Pointer to a Net system service callback function.

Description

This data type defines a pointer to a Net service callback function, thus defining the function signature. Callback functions may be registered by clients of the net service when opening a Net socket via the Initialize call.

Precondition

Is a part of the Net service initialization using the SYS_NET_Open function.

Parameters

event - An event (SYS_NET_EVENT) for which the callback was called. data - Data (if any) related to the Event | Param | Description | |:----- |:----------- |

| cookie | A context value, returned untouched to the client when the callback occurs.

Returns

None.

Example

void NetServCallback(uint32_t event, void *data, void* cookie, )
{
    switch(event)
    {
        case SYS_NET_EVNT_CONNECTED:
        {
            SYS_CONSOLE_PRINT("NetServCallback(): Status UP");
            while(SYS_NET_SendMsg(g_NetServHandle, "hello", 5) == 0);
            break;
        }
        
        case SYS_NET_EVNT_DISCONNECTED:
        {
            SYS_CONSOLE_PRINT("NetServCallback(): Status DOWN");
            break;
        }
        
        case SYS_NET_EVNT_RCVD_DATA:
        {
            int32_t len = 32;
        uint8_t buffer[32] = {0};
            len = SYS_NET_RecvMsg(g_NetServHandle, buffer, len);
            SYS_CONSOLE_PRINT("NetServCallback(): Data Rcvd = %s", buffer);
            break;
        }
    }
}

Remarks

None.