This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SIMPLELINK-WIFI-CC3120-SDK-PLUGIN: "network_terminal" application uses incorrect NetApp event codes

Part Number: SIMPLELINK-WIFI-CC3120-SDK-PLUGIN
Other Parts Discussed in Thread: CC3120,

I've been porting the CC3120 SDK into my microcontroller project, and I've been examining the "network_terminal" application as an example of how to construct a working application, in terms of handling events, etc.  I'm making a point to write robust events handlers, so that at a minimum, I will catch and report each possible event ID for each event type, even if I do nothing with it.

I finished the section for WLAN events, and next up are the NetApp events.  I was a bit confused about the nomenclature of the event IDs used in the network terminal example:

void SimpleLinkNetAppEventHandler(SlNetAppEvent_t *pNetAppEvent)
{
    if (!pNetAppEvent)
        return;
    switch (pNetAppEvent->Id)
    {
        case SL_DEVICE_EVENT_DROPPED_NETAPP_IPACQUIRED:
            [...]
        case SL_DEVICE_EVENT_DROPPED_NETAPP_IPACQUIRED_V6:
            [...]
        case SL_DEVICE_EVENT_DROPPED_NETAPP_IP_LEASED:
            [...]
        case SL_DEVICE_EVENT_DROPPED_NETAPP_IP_RELEASED:
        {
            UART_PRINT("\n\r[NETAPP EVENT] IP is released.\n\r");
        }
        break;
    }
}

"Event Dropped", what's that about?  I did a search and found all of the relevant macros in device.h:

/******************  NETAPP CLASS status ****************/
#define SL_DEVICE_EVENT_DROPPED_NETAPP_IPACQUIRED                        (0x00000001L)
#define SL_DEVICE_EVENT_DROPPED_NETAPP_IPACQUIRED_V6                     (0x00000002L)
#define SL_DEVICE_EVENT_DROPPED_NETAPP_IP_LEASED                         (0x00000004L)
#define SL_DEVICE_EVENT_DROPPED_NETAPP_IP_RELEASED                       (0x00000008L)
#define SL_DEVICE_EVENT_DROPPED_NETAPP_IPV4_LOST                         (0x00000010L)
#define SL_DEVICE_EVENT_DROPPED_NETAPP_DHCP_ACQUIRE_TIMEOUT              (0x00000020L)
#define SL_DEVICE_EVENT_DROPPED_NETAPP_IP_COLLISION                      (0x00000040L)
#define SL_DEVICE_EVENT_DROPPED_NETAPP_IPV6_LOST                         (0x00000080L)

Hmm, OK, that certainly looks like a list of events.  But from doing the WLAN events, I knew that those event IDs were in wlan.h.  So I thought, wait, why are NetApp event IDs in device.h?  So I looked in netapp.h and here's what I found:

/* NetApp user events */   
typedef enum
{
	SL_NETAPP_EVENT_IPV4_ACQUIRED = 1,
	SL_NETAPP_EVENT_IPV6_ACQUIRED,
	SL_NETAPP_EVENT_IP_COLLISION,
	SL_NETAPP_EVENT_DHCPV4_LEASED,
	SL_NETAPP_EVENT_DHCPV4_RELEASED,
	SL_NETAPP_EVENT_HTTP_TOKEN_GET,
	SL_NETAPP_EVENT_HTTP_TOKEN_POST,
	SL_NETAPP_EVENT_IPV4_LOST,
	SL_NETAPP_EVENT_DHCP_IPV4_ACQUIRE_TIMEOUT,
	SL_NETAPP_EVENT_IPV6_LOST,
	SL_NETAPP_EVENT_MAX
} SlNetAppEventId_e;

Now I'm thinking, wait, these look like the macros/enumerations I should be using, not the "SL_DEVICE_EVENT_DROPPED" macros.  But wait, how did the network terminal app ever work if it was using the wrong macros?

The answer: sheer bloody coincidence.

Device macro NetApp enum Integer value
SL_DEVICE_EVENT_DROPPED_NETAPP_IPACQUIRED
SL_NETAPP_EVENT_IPV4_ACQUIRED
1 (0x00000001L)
SL_DEVICE_EVENT_DROPPED_NETAPP_IPACQUIRED_V6
SL_NETAPP_EVENT_IPV6_ACQUIRED
2 (0x00000002L)
SL_DEVICE_EVENT_DROPPED_NETAPP_IP_LEASED
SL_NETAPP_EVENT_DHCPV4_LEASED
4 (0x00000004L)
SL_DEVICE_EVENT_DROPPED_NETAPP_IP_RELEASED
SL_NETAPP_EVENT_IPV4_LOST
8 (0x00000008L)

By pure luck, the Device.h macros, which are intended to be bitmasks, happened to equal the value of the relevant NetApp event IDs.  In the case of "IP released", the network terminal app was actually reporting the "IPv4 Lost" event, which likely coincides with the DHCPv4 lease released event.

I searched through the rest of the SDK directory, and the "network_terminal" app is the only one that appears to misuse the "SL_DEVICE_EVENT_DROPPED" macros; all the other example applications use the "SL_NETAPP_EVENT" enumerations as intended.

However, the problem is that "network_terminal" is kinda your featured example application for users of the CC3120 SDK.  And I've found at least two examples in the forums, linked here and here, where users have duplicated the misuse of these macros, so they're obviously getting that behavior from the example.

The "network_terminal" example needs to have its SimpleLinkNetAppEventHandler() function corrected, so that users know to use the "SL_NETAPP_EVENT" enumerations as intended.

(Currently using simplelink_msp432_sdk_wifi_plugin_1_40_00_02)

  • Hi,

    Thanks for reporting this. Changes will be made in the next SDK release.

    regards,
    Charles O
  • Hi,

    I reviewed the latest version of the SDK and the issue has been fixed. Please download the latest SDK.

    Regards,

    Charles O

  • Downloading it now. (digressing for a moment...) Of course, I might have known that a new SDK version had been released if TI's notification mechanism for new releases actually worked. The new SDK was released on November 2, TI.com just confirmed that "You already have an alert for SIMPLELINK-WIFI-CC3120-SDK-PLUGIN: SimpleLink™ WI-FI® CC3120 SDK Plugin", and nothing in my inbox, spam, trash, or TI folder resembles a new release notification. Having to set an alert for each individual document or download, and then download and separately install each SDK or tool, is such a dated process, and TI would do well to come up with a more modern way of distributing and deploying its software products. There's no reason why Code Composer Studio couldn't become the hub for these tools, a la Simplicity Studio (Silicon Labs), Atmel Studio (Atmel/Microchip), MPLAB X (Microchip), etc.
  • Dear DR216 -

    FYI, Resource Explorer (inside CCS or the Cloud based version) does have what you describe

    inside CCS ==>