1.10.1 Application Example

The Metering Demo G3 Device UDP/ICMPv6 Responder application implements a metering application and a G3-Hybrid Device, capable of joining a G3 network. Once it is joined it can reply to UDP and ICMPv6 requests. It demonstrates how to send metrology data through UDP.

This application can be used to pass the G3 Conformance certification tests. By default the application is not configured for G3 Conformance tests. In order to configure it, the function APP_G3_MANAGEMENT_SetConformanceConfig() must be called. In the provided example this is done at initialization if macro APP_G3_MANAGEMENT_CONFORMANCE_TEST is defined, but the user could implement another method to configure it dynamically.

The Metering Demo G3 Device UDP/ICMPv6 Responder application implements a console through a serial port, where the user can introduce commands. The settings of the serial port are:
  • Baud-rate 115200 bps
  • 8 data bits
  • no parity
  • 1 stop bit
In order to separate functionalities, there are eleven application files, each one with its own state machine:
  • Metrology (app_metrology.c): Handles the metrology driver and its configuration.
  • Energy (app_energy.c): Interacts with the metrology application to gather energy consumption. Energy consumption is assigned and grouped into different time zones. This application also manages the RTC peripheral.
  • Events (app_events.c): Interacts with the metrology application to store the event happening and its occurrence time.
  • Console (app_console.c): Interacts with the application using a serial port to send commands to the board and receive data.
  • Datalog (app_datalog.c): Writes/Reads data information to/from the external flash memory.
  • Display (app_display.c): Navigates through the different data shown in the display using the buttons Scroll Down and Scroll up of the demo boards.
  • 1.7.1.1 G3 Management (app_g3_management.c): It manages the G3 stack, including:
    • Network discovery and join.
    • Configuration of G3 stack (ADP, MAC and LBP) parameters, including specific configuration for G3 Conformance tests.
  • 1.7.1.2 TCP/IP Management (app_tcpip_management.c): It configures the TCP/IP stack, including:
    • Set IPv6 addresses.
    • Specific configuration for the G3 stack.
  • 1.7.1.3 UDP Responder (app_udp_responder.c): It opens an UDP server socket and handles the messages defined in G3 Conformance tests.
  • UDP Metrology (app_udp_metrology.c): It opens an UDP server socket (port 0xF0B0) and sends metrology data through UDP when requested.
  • 1.7.1.4 Storage: It contains the Extended Address (EUI64) generation and non-volatile data storage.
    • For PIC32CXMT (app_storate_pic32cxmt.c) it is implemented using UniqueID, User Signature, GPBR and SUPC power-down detection.

For more information about metering demo, please refer to its documentation (smartenergy repository).