TI-OpenThread  1.08.06.06
Macros | Functions | Variables
LP_CC2674R10_FPGA/thread/door_lock/doorlock.c File Reference
#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"
+ Include dependency graph for LP_CC2674R10_FPGA/thread/door_lock/doorlock.c:

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]
 

Macro Definition Documentation

§ ATTR_READ

#define ATTR_READ   0x01

Referenced by setupCoapServer().

§ ATTR_WRITE

#define ATTR_WRITE   0x02

Referenced by setupCoapServer().

§ ATTR_REPORT

#define ATTR_REPORT   0x04

§ DOORLOCK_PROC_QUEUE_MAX_MSG

#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().

Function Documentation

§ 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.

Returns
None Door lock processing thread.

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().

§ coapHandleServer()

static void coapHandleServer ( void *  aContext,
otMessage *  aMessage,
const otMessageInfo *  aMessageInfo 
)
static

Callback function registered with the Coap server. Processes the coap request from the clients.

Parameters
aContextA pointer to the context information.
aMessageA pointer to the message.
aMessageInfoA pointer to the message info.
Returns
None

References app_postEvt(), attrState, DoorLock_evtLock, DoorLock_evtUnlock, DOORLOCK_STATE_LOCK, and DOORLOCK_STATE_UNLOCK.

Referenced by setupCoapServer().

§ setupCoapServer()

static otError setupCoapServer ( otInstance *  aInstance,
const attrDesc_t *  attr 
)
static

sets up the application coap server.

Parameters
aInstanceA pointer to the context information.
attrAttribute data
Returns
OT_ERROR_NONE if successful, else error code

References app_postEvt(), ATTR_READ, ATTR_WRITE, coapHandleServer(), coapResource, DoorLock_evtKeyRight, KEYS_RIGHT, keysPressed, OtRtosApi_lock(), OtRtosApi_unlock(), and processKeyChangeCB().

Referenced by processEvent().

§ processKeyChangeCB()

void processKeyChangeCB ( Button_Handle  _buttonHandle,
Button_EventMask  _buttonEvents 
)

Handles the key press events.

Handles the key pressed events for examples.

Parameters
_buttonHandleidentifies which keys were pressed
_buttonEventsidentifies the event that occurred on the key
Returns
None

References app_postEvt(), DoorLock_evtKeyRight, and rightButtonHandle.

Referenced by DoorLock_task(), and setupCoapServer().

§ processOtStackEvents()

static void processOtStackEvents ( uint8_t  event,
void *  aContext 
)
static

Processes the OT stack events.

Parameters
eventevent identifier
aContextcontext pointer for the event
Returns
None

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().

§ processEvent()

static void processEvent ( appEvent_e  event)
static

§ otPlatUartReceived()

void otPlatUartReceived ( const uint8_t *  aBuf,
uint16_t  aBufLength 
)

Documented in openthread/platform/uart.h.

§ otPlatUartSendDone()

void otPlatUartSendDone ( void  )

Documented in openthread/platform/uart.h.

§ app_postEvt()

void app_postEvt ( appEvent_e  event)

§ DoorLock_taskCreate()

void DoorLock_taskCreate ( void  )

Variable Documentation

§ Doorlock_procQueueName

const char Doorlock_procQueueName[] = "/dl_process"

Referenced by DoorLock_task().

§ Doorlock_procQueueDesc

mqd_t Doorlock_procQueueDesc
static

Referenced by app_postEvt(), and DoorLock_task().

§ stack

Referenced by DoorLock_taskCreate().

§ coapResource

otCoapResource coapResource
static

Referenced by setupCoapServer().

§ attrState

uint8_t attrState[15] = DOORLOCK_STATE_UNLOCK
static

§ coapAttr

const attrDesc_t coapAttr
Initial value:
= {
}
#define ATTR_WRITE
Definition: LP_CC2674R10_FPGA/thread/door_lock/doorlock.c:127
#define ATTR_READ
Definition: LP_CC2674R10_FPGA/thread/door_lock/doorlock.c:125
static uint8_t attrState[15]
Definition: LP_CC2674R10_FPGA/thread/door_lock/doorlock.c:172
#define DOORLOCK_STATE_URI
Definition: CC1352P_2_LAUNCHXL/thread/door_lock/doorlock.h:62

Referenced by processEvent().

§ serverSetup

bool serverSetup = false
static

Referenced by processEvent().

§ rightButtonHandle

Button_Handle rightButtonHandle
static

§ statusBuf

char statusBuf[MAX_STATUS_LINE_VALUE_LEN]
static

Referenced by DoorLock_task(), and processEvent().

© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale