![]() |
![]() |
TI-OpenThread
1.08.06.06
|
#include <openthread/config.h>
#include <openthread-core-config.h>
#include <assert.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <openthread/coap.h>
#include <openthread/dataset.h>
#include <openthread/platform/uart.h>
#include <openthread/tasklet.h>
#include <openthread/thread.h>
#include <sched.h>
#include <pthread.h>
#include <mqueue.h>
#include <ti/drivers/GPIO.h>
#include <ti/drivers/apps/Button.h>
#include <ti/drivers/apps/LED.h>
#include "otsupport/otrtosapi.h"
#include "otsupport/otinstance.h"
#include "ti_drivers_config.h"
#include "images.h"
#include "doorlock.h"
#include "utils/code_utils.h"
#include "tiop_ui.h"
#include "disp_utils.h"
#include "otstack.h"
#include "task_config.h"
#include "tiop_config.h"
Macros | |
#define | ATTR_READ 0x01 |
#define | ATTR_REPORT 0x04 |
#define | ATTR_WRITE 0x02 |
#define | DOORLOCK_PROC_QUEUE_MAX_MSG (11) |
Size of the message queue for Doorlock_procQueue More... | |
Functions | |
void | app_postEvt (appEvent_e event) |
Posts an event to the Door Lock task. More... | |
static void | coapHandleServer (void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo) |
Callback function registered with the Coap server. Processes the coap request from the clients. More... | |
void * | DoorLock_task (void *arg0) |
Invalidate the OAD IMAGE HEADER. More... | |
void | DoorLock_taskCreate (void) |
void | otPlatUartReceived (const uint8_t *aBuf, uint16_t aBufLength) |
void | otPlatUartSendDone (void) |
static void | processEvent (appEvent_e event) |
Processes the events. More... | |
void | processKeyChangeCB (Button_Handle _buttonHandle, Button_EventMask _buttonEvents) |
Handles the key press events. More... | |
static void | processOtStackEvents (uint8_t event, void *aContext) |
Processes the OT stack events. More... | |
static otError | setupCoapServer (otInstance *aInstance, const attrDesc_t *attr) |
sets up the application coap server. More... | |
Variables | |
static uint8_t | attrState [15] = DOORLOCK_STATE_UNLOCK |
const attrDesc_t | coapAttr |
static otCoapResource | coapResource |
static mqd_t | Doorlock_procQueueDesc |
const char | Doorlock_procQueueName [] = "/dl_process" |
static Button_Handle | rightButtonHandle |
static bool | serverSetup = false |
static char | stack [TASK_CONFIG_DOORLOCK_TASK_STACK_SIZE] |
static char | statusBuf [MAX_STATUS_LINE_VALUE_LEN] |
#define ATTR_READ 0x01 |
Referenced by setupCoapServer().
#define ATTR_WRITE 0x02 |
Referenced by setupCoapServer().
#define ATTR_REPORT 0x04 |
#define DOORLOCK_PROC_QUEUE_MAX_MSG (11) |
Size of the message queue for Doorlock_procQueue
There are 10/13 events that can be raised, it is unlikely that they will all be raised at the same time. Add one buffer queue element.
Referenced by DoorLock_task().
void* DoorLock_task | ( | void * | arg0 | ) |
Invalidate the OAD IMAGE HEADER.
This provides a way to revert to factory image by invalidating the existing stack/application image and doing a system reset. On boot, the BIM on finding the internal invalidated image will restore to factory image.
References attrState, CUI_COLOR_CYAN, CUI_COLOR_RESET, CUI_COLOR_WHITE, DISPUTILS_LCDPRINTF, DispUtils_open(), DISPUTILS_SERIALPRINTF, DOORLOCK_PROC_QUEUE_MAX_MSG, Doorlock_procQueueDesc, Doorlock_procQueueName, extAddress, KeysUtils_initialize(), OtInstance_get(), OtRtosApi_lock(), OtRtosApi_unlock(), OtStack_registerCallback(), OtStack_setupInterfaceAndNetwork(), OtStack_taskCreate(), processEvent(), processKeyChangeCB(), processOtStackEvents(), rightButtonHandle, statusBuf, and tiopCUIInit().
Referenced by DoorLock_taskCreate().
|
static |
Callback function registered with the Coap server. Processes the coap request from the clients.
aContext | A pointer to the context information. |
aMessage | A pointer to the message. |
aMessageInfo | A pointer to the message info. |
References app_postEvt(), attrState, DoorLock_evtLock, DoorLock_evtUnlock, DOORLOCK_STATE_LOCK, and DOORLOCK_STATE_UNLOCK.
Referenced by setupCoapServer().
|
static |
sets up the application coap server.
aInstance | A pointer to the context information. |
attr | Attribute data |
References app_postEvt(), ATTR_READ, ATTR_WRITE, coapHandleServer(), coapResource, DoorLock_evtKeyRight, KEYS_RIGHT, keysPressed, OtRtosApi_lock(), OtRtosApi_unlock(), and processKeyChangeCB().
Referenced by processEvent().
void processKeyChangeCB | ( | Button_Handle | _buttonHandle, |
Button_EventMask | _buttonEvents | ||
) |
Handles the key press events.
Handles the key pressed events for examples.
_buttonHandle | identifies which keys were pressed |
_buttonEvents | identifies the event that occurred on the key |
References app_postEvt(), DoorLock_evtKeyRight, and rightButtonHandle.
Referenced by DoorLock_task(), and setupCoapServer().
|
static |
Processes the OT stack events.
event | event identifier |
aContext | context pointer for the event |
References app_postEvt(), DoorLock_evtDevRoleChanged, DoorLock_evtNwkJoined, DoorLock_evtNwkJoinFailure, DoorLock_evtNwkSetup, OT_STACK_EVENT_DEV_ROLE_CHANGED, OT_STACK_EVENT_NWK_DATA_CHANGED, OT_STACK_EVENT_NWK_JOINED, and OT_STACK_EVENT_NWK_JOINED_FAILURE.
Referenced by DoorLock_task().
|
static |
Processes the events.
event | event to process in the switch |
References attrState, coapAttr, CUI_COLOR_CYAN, CUI_COLOR_RESET, CUI_COLOR_WHITE, CUI_conn_join_fail, CUI_conn_joined, CUI_conn_joining, CUI_processMenuUpdate(), DispUtils_lcdDraw(), DISPUTILS_LCDPRINTF, DISPUTILS_SERIALPRINTF, DoorLock_evtDevRoleChanged, DoorLock_evtKeyRight, DoorLock_evtLock, DoorLock_evtNwkJoined, DoorLock_evtNwkJoinFailure, DoorLock_evtNwkSetup, DoorLock_evtUnlock, doorLockImage, doorUnlockImage, OAD_CtrlRegEvt, OAD_open(), OAD_pause(), OAD_processCtrlEvents(), OAD_processQueue(), OAD_queueEvt, OT_STACK_EVENT_NWK_JOIN_IN_PROGRESS, OtInstance_get(), OtRtosApi_lock(), OtRtosApi_unlock(), OtStack_joinConfiguredNetwork(), OtStack_joinState(), OtStack_setupInterfaceAndNetwork(), OtStack_setupNetwork(), serverSetup, setupCoapServer(), statusBuf, tiopCUIUpdateApp(), tiopCUIUpdateChannel(), tiopCUIUpdateConnStatus(), tiopCUIUpdateExtPANID(), tiopCUIUpdateMasterkey(), tiopCUIUpdateNwkName(), tiopCUIUpdatePANID(), tiopCUIUpdateRole(), and tiopCUIUpdateShortAddr().
Referenced by DoorLock_task().
void otPlatUartReceived | ( | const uint8_t * | aBuf, |
uint16_t | aBufLength | ||
) |
Documented in openthread/platform/uart.h.
void otPlatUartSendDone | ( | void | ) |
Documented in openthread/platform/uart.h.
void app_postEvt | ( | appEvent_e | event | ) |
Posts an event to the Door Lock task.
event | event to post. |
References attrState, CUI_ITEM_INTERCEPT_START, DoorLock_evtLock, DoorLock_evtUnlock, Doorlock_procQueueDesc, DOORLOCK_STATE_LOCK, DOORLOCK_STATE_UNLOCK, doorlock_toggleLock(), MAX_MENU_LINE_LEN, OtInstance_get(), OtRtosApi_lock(), OtRtosApi_unlock(), processMenuUpdateFn(), tiopCUINwkReset(), tiopCUIReset(), uiActionAttach(), and uiActionJoin().
Referenced by coapHandleServer(), processKeyChangeCB(), processOtStackEvents(), and setupCoapServer().
void DoorLock_taskCreate | ( | void | ) |
Documented in task_config.h.
References DoorLock_task(), img_header_single_app::h, img_common_header::imgID, oad_image_header, stack, TASK_CONFIG_DOORLOCK_TASK_PRIORITY, and TASK_CONFIG_DOORLOCK_TASK_STACK_SIZE.
const char Doorlock_procQueueName[] = "/dl_process" |
Referenced by DoorLock_task().
|
static |
Referenced by app_postEvt(), and DoorLock_task().
|
static |
Referenced by DoorLock_taskCreate().
|
static |
Referenced by setupCoapServer().
|
static |
Referenced by app_postEvt(), coapHandleServer(), DoorLock_task(), and processEvent().
const attrDesc_t coapAttr |
Referenced by processEvent().
|
static |
Referenced by processEvent().
|
static |
Referenced by DoorLock_task(), and processKeyChangeCB().
|
static |
Referenced by DoorLock_task(), and processEvent().