OTAU implementation.
Copyright (c) 2018 - 2019 Microchip Technology Inc. and its subsidiaries.
#include "compiler.h"
#include "asf.h"
#include "otau.h"
#include "system.h"
#include "sysTimer.h"
#include "common_nvm.h"
#include "miwi_api.h"
#include "mimem.h"
#include "miqueue.h"
#include "otau_notify.h"
#include "otau_upgrade.h"
#include "otau_debug.h"
Functions | |
static bool | addDataHandleTableEntry (uint8_t domainId, uint8_t messageId, addr_mode_t addrMode, uint8_t *addr, uint8_t handle) |
uint8_t * | get_node_address (addr_mode_t addr_mode) |
static bool | getAddressFromDataHandleTable (uint8_t handle, uint8_t *domainId, uint8_t *messageId, uint8_t *addrMode, uint8_t *addr) |
static void | initDataHandleTable (void) |
static void | otauDataConf (uint8_t msgConfHandle, miwi_status_t status, uint8_t *msgPointer) |
static void | otauDataInd (RECEIVED_MESH_MESSAGE *ind) |
void | otauDataSend (addr_mode_t addr_mode, uint8_t *addr, void *payload, uint16_t len) |
void | otauGetServerDetails (addr_mode_t addr_mode, uint8_t *addr) |
void | otauHandleMsg (otau_domain_msg_t *otau_domain_msg) |
void | otauInit (void) |
void | otauLed (otau_led_t led_state) |
void | otauRcvdFrame (otau_rcvd_frame_t *frame) |
void | otauResetDevice (void) |
void | otauSetServerDetails (addr_mode_t addr_mode, uint8_t *addr) |
void | otauTask (void) |
void | otauTimerStart (otau_domain_t domain_code, uint32_t interval, otau_timer_mode_t mode) |
void | otauTimerStop (otau_domain_t domain_code) |
void | reverseMemcpy (uint8_t *dst, uint8_t *src, uint8_t len) |
Variables | |
DataHandleTable_t | dataHandleTable [DATA_HANDLE_TABLE_SIZE] |
static uint8_t | msgHandle = 0 |
MiQueue_t | networkFrame |
static SYS_Timer_t | otauDebugTimer |
static bool | otauInited = false |
static SYS_Timer_t | otauNotifyTimer |
static SYS_Timer_t | otauUpgradeTimer |
uint16_t | pan_id = MY_PAN_ID |
uint8_t | seq_no = 0 |
node_address_t | serverAddress |
uint16_t | shortAddress |
|
static |
References DataHandleTable_::addrMode, DATA_HANDLE_TABLE_SIZE, DataHandleTable_::dataHandle, DataHandleTable_::domainId, DataHandleTable_::messageId, and SHORT_ADDR_LEN.
Referenced by otauDataSend().
uint8_t* get_node_address | ( | addr_mode_t | addr_mode | ) |
References myLongAddress, NATIVE_ADDR_MODE, and shortAddress.
Referenced by otauClientSendNotify(), and otauDataSend().
|
static |
References DataHandleTable_::addrMode, DATA_HANDLE_TABLE_SIZE, dataHandle, DataHandleTable_::domainId, DataHandleTable_::messageId, and SHORT_ADDR_LEN.
Referenced by otauDataConf().
|
static |
References DATA_HANDLE_TABLE_SIZE, DataHandleTable_::domainId, and DataHandleTable_::messageId.
Referenced by otauInit().
|
static |
References CHANNEL_ACCESS_FAILURE, DOMAIN_OTAU_DEBUG, DOMAIN_OTAU_NOTIFY, DOMAIN_OTAU_UPGRADE, getAddressFromDataHandleTable(), NATIVE_ADDR_MODE, NO_ACK, OTAU_CCA_FAILURE, OTAU_ERROR, OTAU_NO_ACK, OTAU_SUCCESS, otauDebugSentFrame(), otauNotifySentFrame(), otauUpgradeSentFrame(), and SUCCESS.
Referenced by otauDataSend().
|
static |
References otau_rcvd_frame_t::addr_mode, otau_rcvd_frame_t::frame_length, otau_rcvd_frame_t::frame_payload, MiMem_Alloc(), miQueueAppend(), NATIVE_ADDR_MODE, NATIVE_ADDR_SIZE, NULL, RECEIVED_MESH_MESSAGE::payload, RECEIVED_MESH_MESSAGE::payloadSize, RECEIVED_MESH_MESSAGE::sourceAddress, and otau_rcvd_frame_t::src_addr.
Referenced by otauInit().
void otauDataSend | ( | addr_mode_t | addr_mode, |
uint8_t * | addr, | ||
void * | payload, | ||
uint16_t | len | ||
) |
References addDataHandleTableEntry(), BROADCAST_MODE, DOMAIN_OTAU_DEBUG, DOMAIN_OTAU_NOTIFY, DOMAIN_OTAU_UPGRADE, node_address_t::extended_addr, EXTENDED_ADDR_MODE, FCF_LONG_ADDR, get_node_address(), MESH_BROADCAST_TO_ALL, MiApp_Get(), MiApp_ManuSpecSendData(), msgHandle, node_address_t::native_addr, NATIVE_ADDR_MODE, NULL, OTAU_ERROR, otauDataConf(), otauDebugSentFrame(), otauNotifySentFrame(), otauUpgradeSentFrame(), PANID, and SHORT_ADDR_LEN.
Referenced by otauClientSendNotify(), otauDebugRcvdFrame(), otauDebugTimerHandler(), otauNotifyRcvdFrame(), send_image_req(), and send_switch_req().
void otauGetServerDetails | ( | addr_mode_t | addr_mode, |
uint8_t * | addr | ||
) |
References node_address_t::extended_addr, node_address_t::native_addr, and NATIVE_ADDR_MODE.
Referenced by send_image_req(), and send_switch_req().
void otauHandleMsg | ( | otau_domain_msg_t * | otau_domain_msg | ) |
References DOMAIN_OTAU_DEBUG, DOMAIN_OTAU_NOTIFY, DOMAIN_OTAU_UPGRADE, otau_domain_msg_t::domainId, otauHandleDebugMsg(), otauHandleNotifyMsg(), and otauHandleUpgradeMsg().
Referenced by otauTask().
void otauInit | ( | void | ) |
References initDataHandleTable(), MiApp_SubscribeManuSpecDataIndicationCallback(), miQueueInit(), otauDataInd(), otauDebugInit(), otauNotifyInit(), otauParserInit(), and otauUpgradeInit().
Referenced by otauTask().
void otauLed | ( | otau_led_t | led_state | ) |
References OTAU_LED_OFF, and OTAU_LED_ON.
Referenced by otauNotifyTimerHandler().
void otauRcvdFrame | ( | otau_rcvd_frame_t * | frame | ) |
void otauResetDevice | ( | void | ) |
Referenced by otauNotifyRcvdFrame(), and otauUpgradeTimerHandler().
void otauSetServerDetails | ( | addr_mode_t | addr_mode, |
uint8_t * | addr | ||
) |
References node_address_t::extended_addr, EXTENDED_ADDR_SIZE, node_address_t::native_addr, NATIVE_ADDR_MODE, and NATIVE_ADDR_SIZE.
Referenced by otauNotifyRcvdFrame(), and otauUpgradeRcvdFrame().
void otauTask | ( | void | ) |
References dataFromTool, event, MiApp_Get(), MiApp_IsConnected(), MiMem_Free(), miQueueRemove(), NULL, otauHandleMsg(), otauInit(), otauInited, otauRcvdFrame(), serialDataHandler(), SHORT_ADDRESS, shortAddress, and MiQueue::size.
Referenced by main().
void otauTimerStart | ( | otau_domain_t | domain_code, |
uint32_t | interval, | ||
otau_timer_mode_t | mode | ||
) |
References DOMAIN_OTAU_DEBUG, DOMAIN_OTAU_NOTIFY, DOMAIN_OTAU_UPGRADE, SYS_Timer_t::handler, SYS_Timer_t::interval, SYS_Timer_t::mode, otauDebugTimerHandler(), otauNotifyTimerHandler(), otauUpgradeTimerHandler(), SYS_TIMER_INTERVAL_MODE, SYS_TIMER_PERIODIC_MODE, SYS_TimerStart(), SYS_TimerStarted(), SYS_TimerStop(), and TIMER_MODE_SINGLE.
Referenced by otauClientStartTimer(), otauDebugRcvdFrame(), otauDebugTimerHandler(), otauNotifyRcvdFrame(), otauUpgradeRcvdFrame(), otauUpgradeSentFrame(), otauUpgradeTimerHandler(), and send_image_req().
void otauTimerStop | ( | otau_domain_t | domain_code | ) |
References DOMAIN_OTAU_DEBUG, DOMAIN_OTAU_NOTIFY, DOMAIN_OTAU_UPGRADE, and SYS_TimerStop().
Referenced by otauClientStartTimer(), otauDebugTimerHandler(), otauUpgradeRcvdFrame(), otauUpgradeTimerHandler(), and send_image_req().
void reverseMemcpy | ( | uint8_t * | dst, |
uint8_t * | src, | ||
uint8_t | len | ||
) |
References i.
DataHandleTable_t dataHandleTable[DATA_HANDLE_TABLE_SIZE] |
|
static |
Referenced by otauDataSend().
MiQueue_t networkFrame |
|
static |
Referenced by otauTask().
|
static |
|
static |
uint16_t pan_id = MY_PAN_ID |
uint8_t seq_no = 0 |
node_address_t serverAddress |
Referenced by otauClientSendNotify().
uint16_t shortAddress |
Referenced by get_node_address(), and otauTask().