WSNDemo application implementation.
Copyright (c) 2018 - 2022 Microchip Technology Inc. and its subsidiaries.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "config.h"
#include "phy.h"
#include "sysTimer.h"
#include "commands.h"
#include "miwi_api.h"
#include "otau.h"
#include "sio2host.h"
#include "sleep_mgr.h"
#include "sysclk.h"
#include "asf.h"
#include "wsndemo.h"
#include "pdsMemIds.h"
#include "pdsDataServer.h"
#include "wlPdsTaskManager.h"
Data Structures | |
struct | AppMessage_t |
Macros | |
#define | APP_CAPTION_SIZE (sizeof(APP_CAPTION) - 1 + SHORT_ADDRESS_CAPTION_SIZE) |
#define | APP_SCAN_DURATION 10 |
Typedefs | |
typedef struct AppMessage_t | AppMessage_t |
typedef enum AppState_t | AppState_t |
Functions | |
static void | APP_TaskHandler (void) |
static void | appDataConf (uint8_t msgConfHandle, miwi_status_t status, uint8_t *msgPointer) |
static void | appDataInd (RECEIVED_MESH_MESSAGE *ind) |
static void | appDataSendingTimerHandler (SYS_Timer_t *timer) |
static void | appInit (void) |
static void | appNetworkStatusTimerHandler (SYS_Timer_t *timer) |
static void | appSendData (void) |
static void | appUartSendMessage (uint8_t *data, uint8_t size) |
static void | Connection_Confirm (miwi_status_t status) |
Connection confirmation. More... | |
static void | ReconnectionIndication (miwi_status_t status) |
void | UartBytesReceived (uint16_t bytes, uint8_t *byte) |
void | wsndemo_init (void) |
Init function of the WSNDemo application. More... | |
void | wsndemo_task (void) |
Task of the WSNDemo application This task should be called in a while(1) More... | |
Variables | |
SYS_Timer_t | appDataSendingTimer |
static AppMessage_t | appMsg |
static bool | appNetworkStatus |
static SYS_Timer_t | appNetworkStatusTimer |
static AppState_t | appState = APP_STATE_INITIAL |
static uint8_t | rx_data [APP_RX_BUF_SIZE] |
#define APP_CAPTION_SIZE (sizeof(APP_CAPTION) - 1 + SHORT_ADDRESS_CAPTION_SIZE) |
Referenced by appInit(), and appSendData().
#define APP_SCAN_DURATION 10 |
Referenced by APP_TaskHandler().
typedef struct AppMessage_t AppMessage_t |
typedef enum AppState_t AppState_t |
enum AppState_t |
|
static |
References APP_RX_BUF_SIZE, APP_SCAN_DURATION, APP_SENDING_INTERVAL, APP_STATE_CONNECT_NETWORK, APP_STATE_CONNECTING_NETWORK, APP_STATE_PREPARE_TO_SLEEP, APP_STATE_RECONNECT_FAILURE, APP_STATE_RECONNECT_SUCCESS, APP_STATE_SEND, APP_STATE_SENDING_DONE, APP_STATE_START_NETWORK, APP_STATE_WAIT_CONF, APP_STATE_WAIT_SEND_TIMER, appCmdIdentifyDurationTimer, appCmdIdentifyPeriodTimer, appInit(), appSendData(), appState, CHANNEL_MAP, Connection_Confirm(), MiApp_ReadyToSleep(), MiApp_ResetToFactoryNew(), MiApp_SearchConnection(), MiApp_StartConnection(), port_pin_get_input_level(), sio2host_rx(), sleepMgr_sleep(), START_CONN_DIRECT, SYS_TimerRemainingTimeout(), SYS_TimerStart(), SYS_TimerStarted(), and UartBytesReceived().
Referenced by wsndemo_task().
|
static |
References APP_STATE_SENDING_DONE, APP_STATE_WAIT_CONF, appState, SUCCESS, SYS_TimerStart(), and SYS_TimerStop().
Referenced by appSendData().
|
static |
|
static |
References APP_STATE_PREPARE_TO_SLEEP, APP_STATE_SEND, APP_STATE_WAIT_SEND_TIMER, appState, and SYS_TimerStart().
Referenced by appInit().
|
static |
References APP_CAPTION, APP_CAPTION_SIZE, APP_COMMAND_ID_NETWORK_INFO, APP_CommandsInit(), APP_NODE_TYPE, APP_NWKSTATUS_INTERVAL, APP_SENDING_INTERVAL, APP_STATE_CONNECT_NETWORK, APP_STATE_RECONNECT_SUCCESS, APP_STATE_SEND, APP_STATE_START_NETWORK, appDataInd(), appDataSendingTimerHandler(), appLinkFailureCallback(), appNetworkStatusTimerHandler(), appState, AppMessage_t::battery, AppMessage_t::caption, CHANNEL_MAP, AppMessage_t::channelMask, AppMessage_t::commandId, AppMessage_t::extAddr, SYS_Timer_t::handler, SYS_Timer_t::interval, AppMessage_t::light, AppMessage_t::lqi, MiApp_SubscribeDataIndicationCallback(), MiApp_SubscribeLinkFailureCallback(), SYS_Timer_t::mode, AppMessage_t::nextHopAddr, AppMessage_t::nodeType, AppMessage_t::rssi, AppMessage_t::sensors, AppMessage_t::shortAddr, AppMessage_t::size, AppMessage_t::softVersion, SYS_TIMER_INTERVAL_MODE, SYS_TIMER_PERIODIC_MODE, SYS_TimerStart(), AppMessage_t::temperature, AppMessage_t::text, and AppMessage_t::type.
Referenced by APP_TaskHandler().
|
static |
Referenced by appInit().
|
static |
References APP_CAPTION, APP_CAPTION_SIZE, APP_STATE_SENDING_DONE, APP_STATE_WAIT_CONF, APP_STATE_WAIT_SEND_TIMER, appDataConf(), appState, appUartSendMessage(), AppMessage_t::battery, AppMessage_t::caption, CHANNEL, ENTRY, AppMessage_t::extAddr, AppMessage_t::light, LOG_INFO, MiApp_Get(), MiApp_MeshGetNextHopAddr(), MiApp_SendData(), MIWI_APP, AppMessage_t::nextHopAddr, otau_log(), otau_trace(), PAN_COORDINATOR_SHORT_ADDRESS, AppMessage_t::panId, PANID, RXON_ENDEVICE_ADDRESS_MASK, AppMessage_t::sensors, SHORT_ADDRESS, SHORT_ADDRESS_CAPTION_SIZE, AppMessage_t::shortAddr, AppMessage_t::size, SYS_TimerStart(), AppMessage_t::temperature, AppMessage_t::text, TRACE_ENTRY, AppMessage_t::type, AppMessage_t::workingChannel, and wsnmsghandle.
Referenced by APP_TaskHandler().
|
static |
References i, and sio2host_putchar().
Referenced by appDataInd(), and appSendData().
|
static |
Connection confirmation.
References APP_STATE_CONNECT_NETWORK, APP_STATE_SEND, APP_STATE_START_NETWORK, appState, and SUCCESS.
Referenced by APP_TaskHandler().
|
static |
References APP_STATE_RECONNECT_FAILURE, APP_STATE_RECONNECT_SUCCESS, appState, and SUCCESS.
Referenced by wsndemo_init().
void UartBytesReceived | ( | uint16_t | bytes, |
uint8_t * | byte | ||
) |
References APP_CommandsByteReceived(), and i.
Referenced by APP_TaskHandler().
void wsndemo_init | ( | void | ) |
Init function of the WSNDemo application.
References APP_STATE_WAIT_FOR_RECONNECT_CALLBACK, appState, defaultParamsRamOnly, defaultParamsRomOrRam, i, LONG_ADDR_LEN, MiApp_ProtocolInit(), MiApp_SubscribeReConnectionCallback(), MY_ADDRESS_LENGTH, myLongAddress, PHY_SetIEEEAddr(), RECONNECTION_IN_PROGRESS, ReconnectionIndication(), sio2host_init(), and sleepMgr_init().
Referenced by main().
void wsndemo_task | ( | void | ) |
Task of the WSNDemo application This task should be called in a while(1)
References APP_TaskHandler(), MeshTasks(), and PDS_TaskHandler().
Referenced by main().
SYS_Timer_t appDataSendingTimer |
|
static |
|
static |
|
static |
|
static |
|
static |