Microchip® Advanced Software Framework

wsndemo.c File Reference

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
 

Enumerations

enum  AppState_t {
  APP_STATE_INITIAL,
  APP_STATE_START_NETWORK,
  APP_STATE_CONNECT_NETWORK,
  APP_STATE_CONNECTING_NETWORK,
  APP_STATE_IN_NETWORK,
  APP_STATE_WAIT_FOR_RECONNECT_CALLBACK,
  APP_STATE_RECONNECT_SUCCESS,
  APP_STATE_RECONNECT_FAILURE,
  APP_STATE_SEND,
  APP_STATE_WAIT_CONF,
  APP_STATE_SENDING_DONE,
  APP_STATE_WAIT_SEND_TIMER,
  APP_STATE_WAIT_COMMAND_TIMER,
  APP_STATE_PREPARE_TO_SLEEP,
  APP_STATE_SLEEP
}
 

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
Enumerator
APP_STATE_INITIAL 
APP_STATE_START_NETWORK 
APP_STATE_CONNECT_NETWORK 
APP_STATE_CONNECTING_NETWORK 
APP_STATE_IN_NETWORK 
APP_STATE_WAIT_FOR_RECONNECT_CALLBACK 
APP_STATE_RECONNECT_SUCCESS 
APP_STATE_RECONNECT_FAILURE 
APP_STATE_SEND 
APP_STATE_WAIT_CONF 
APP_STATE_SENDING_DONE 
APP_STATE_WAIT_SEND_TIMER 
APP_STATE_WAIT_COMMAND_TIMER 
APP_STATE_PREPARE_TO_SLEEP 
APP_STATE_SLEEP 

static void appDataConf ( uint8_t  msgConfHandle,
miwi_status_t  status,
uint8_t *  msgPointer 
)
static
static void appDataSendingTimerHandler ( SYS_Timer_t timer)
static
static void appNetworkStatusTimerHandler ( SYS_Timer_t timer)
static

Referenced by appInit().

static void appUartSendMessage ( uint8_t *  data,
uint8_t  size 
)
static

References i, and sio2host_putchar().

Referenced by appDataInd(), and appSendData().

static void Connection_Confirm ( miwi_status_t  status)
static

Connection confirmation.

References APP_STATE_CONNECT_NETWORK, APP_STATE_SEND, APP_STATE_START_NETWORK, appState, and SUCCESS.

Referenced by APP_TaskHandler().

static void ReconnectionIndication ( miwi_status_t  status)
static
void UartBytesReceived ( uint16_t  bytes,
uint8_t *  byte 
)

References APP_CommandsByteReceived(), and i.

Referenced by APP_TaskHandler().

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
AppMessage_t appMsg
static
bool appNetworkStatus
static
SYS_Timer_t appNetworkStatusTimer
static
uint8_t rx_data[APP_RX_BUF_SIZE]
static