initial commit

This commit is contained in:
2022-10-23 23:45:43 -07:00
commit e190fa5193
6450 changed files with 8626944 additions and 0 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,77 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Application framework configuration.
*
* Copyright (c) 2011-2019 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef APP_CFG_H
#define APP_CFG_H
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! \addtogroup APP_FRAMEWORK_DB_API
* \{ */
/** \name App Configuration
* Build-time configuration constants
*/
/**@{*/
/*! \brief Number of application database device records */
#ifndef APP_DB_NUM_RECS
#define APP_DB_NUM_RECS 3
#endif
/*! \brief Number of client characteristic configuration descriptor handles per record */
#ifndef APP_DB_NUM_CCCD
#define APP_DB_NUM_CCCD 10
#endif
/*! \brief Number of ATT client cached handles per record */
#ifndef APP_DB_HDL_LIST_LEN
#define APP_DB_HDL_LIST_LEN 21
#endif
/*! \} */ /* APP_FRAMEWORK_DB_API */
/*! \addtogroup APP_FRAMEWORK_API
* \{ */
/*! \brief Number of scan results to store (used only when operating as master) */
#ifndef APP_SCAN_RESULT_MAX
#define APP_SCAN_RESULT_MAX 10
#endif
/**@}*/
/*! \} */ /*! APP_FRAMEWORK_API */
#ifdef __cplusplus
};
#endif
#endif /* APP_CFG_H */
@@ -0,0 +1,529 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Application framework device database.
*
* Copyright (c) 2011-2019 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef APP_DB_H
#define APP_DB_H
#include "wsf_os.h"
#include "dm_api.h"
#include "att_api.h"
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup APP_FRAMEWORK_DB_API
* \{ */
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! \brief No device database record handle */
#define APP_DB_HDL_NONE NULL
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! \brief Device database record handle type */
typedef void *appDbHdl_t;
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/** \name App Database
* Store known device and security information.
*/
/**@{*/
/*************************************************************************************************/
/*!
* \brief Initialize the device database.
*
* \return None.
*/
/*************************************************************************************************/
void AppDbInit(void);
/*************************************************************************************************/
/*!
* \brief Create a new device database record.
*
* \param addrType Address type.
* \param pAddr Peer device address.
* \param master_role True if local device is master for this record
*
* \return Database record handle.
*/
/*************************************************************************************************/
appDbHdl_t AppDbNewRecord(uint8_t addrType, uint8_t *pAddr, bool_t master_role);
/*************************************************************************************************/
/*!
* \brief Get next device database record for a given database record. For the first database
* record, the function should be called with 'hdl' set to 'APP_DB_HDL_NONE'.
*
* \param hdl Database record handle.
*
* \return Next database record handle found. APP_DB_HDL_NONE, otherwise.
*/
/*************************************************************************************************/
appDbHdl_t AppDbGetNextRecord(appDbHdl_t hdl);
/*************************************************************************************************/
/*!
* \brief Delete a new device database record.
*
* \param hdl Database record handle.
*
* \return None.
*/
/*************************************************************************************************/
void AppDbDeleteRecord(appDbHdl_t hdl);
/*************************************************************************************************/
/*!
* \brief Validate a new device database record. This function is called when pairing is
* successful and the devices are bonded.
*
* \param hdl Database record handle.
* \param keyMask Bitmask of keys to validate.
*
* \return None.
*/
/*************************************************************************************************/
void AppDbValidateRecord(appDbHdl_t hdl, uint8_t keyMask);
/*************************************************************************************************/
/*!
* \brief Check if a record has been validated. If it has not, delete it. This function
* is typically called when the connection is closed.
*
* \param hdl Database record handle.
*
* \return None.
*/
/*************************************************************************************************/
void AppDbCheckValidRecord(appDbHdl_t hdl);
/*************************************************************************************************/
/*!
* \brief Check if a database record is in use.
* \param hdl Database record handle.
*
* \return TURE if record in use. FALSE, otherwise.
*/
/*************************************************************************************************/
bool_t AppDbRecordInUse(appDbHdl_t hdl);
/*************************************************************************************************/
/*!
* \brief Check if there is a stored bond with any device.
*
* \return TRUE if a bonded device is found, FALSE otherwise.
*/
/*************************************************************************************************/
bool_t AppDbCheckBonded(void);
/*************************************************************************************************/
/*!
* \brief Delete all database records.
*
* \return None.
*/
/*************************************************************************************************/
void AppDbDeleteAllRecords(void);
/*************************************************************************************************/
/*!
* \brief Find a device database record by peer address.
*
* \param addrType Address type.
* \param pAddr Peer device address.
*
* \return Database record handle or APP_DB_HDL_NONE if not found.
*/
/*************************************************************************************************/
appDbHdl_t AppDbFindByAddr(uint8_t addrType, uint8_t *pAddr);
/*************************************************************************************************/
/*!
* \brief Find a device database record from data in an LTK request.
*
* \param encDiversifier Encryption diversifier associated with key.
* \param pRandNum Pointer to random number associated with key.
*
* \return Database record handle or APP_DB_HDL_NONE if not found.
*/
/*************************************************************************************************/
appDbHdl_t AppDbFindByLtkReq(uint16_t encDiversifier, uint8_t *pRandNum);
/*************************************************************************************************/
/*!
* \brief Get the device database record handle associated with an open connection.
*
* \param connId Connection identifier.
*
* \return Database record handle or APP_DB_HDL_NONE.
*/
/*************************************************************************************************/
appDbHdl_t AppDbGetHdl(dmConnId_t connId);
/*************************************************************************************************/
/*!
* \brief Get a key from a device database record.
*
* \param hdl Database record handle.
* \param type Type of key to get.
* \param pSecLevel If the key is valid, returns the security level of the key.
*
* \return Pointer to the key if the key is valid or NULL if not valid.
*/
/*************************************************************************************************/
dmSecKey_t *AppDbGetKey(appDbHdl_t hdl, uint8_t type, uint8_t *pSecLevel);
/*************************************************************************************************/
/*!
* \brief Set a key in a device database record.
*
* \param hdl Database record handle.
* \param pKey Key data.
*
* \return None.
*/
/*************************************************************************************************/
void AppDbSetKey(appDbHdl_t hdl, dmSecKeyIndEvt_t *pKey);
/*************************************************************************************************/
/*!
* \brief Get the client characteristic configuration descriptor table.
*
* \param hdl Database record handle.
*
* \return Pointer to client characteristic configuration descriptor table.
*/
/*************************************************************************************************/
uint16_t *AppDbGetCccTbl(appDbHdl_t hdl);
/*************************************************************************************************/
/*!
* \brief Set a value in the client characteristic configuration table.
*
* \param hdl Database record handle.
* \param idx Table index.
* \param value Client characteristic configuration value.
*
* \return None.
*/
/*************************************************************************************************/
void AppDbSetCccTblValue(appDbHdl_t hdl, uint16_t idx, uint16_t value);
/*************************************************************************************************/
/*!
* \brief Get the change aware state and client supported features record.
*
* \param hdl Database record handle.
* \param pIsChangeAware Pointer to peer client's change aware status to a change in the database.
* \param pCsf Pointer to csf value pointer.
*
* \return None.
*/
/*************************************************************************************************/
void AppDbGetCsfRecord(appDbHdl_t hdl, uint8_t *pIsChangeAware, uint8_t **pCsf);
/*************************************************************************************************/
/*!
* \brief Set a client supported features record.
*
* \param hdl Database record handle.
* \param changeAwareState The state of awareness to a change.
* \param pCsf pointed client supported features.
*
* \return None.
*/
/*************************************************************************************************/
void AppDbSetCsfRecord(appDbHdl_t hdl, uint8_t changeAwareState, uint8_t *pCsf);
/*************************************************************************************************/
/*!
* \brief Set client's state of awareness to a change in the database.
*
* \param hdl Database record handle. If \ref hdl == \ref NULL, state is set for all
* clients.
* \param state The state of awareness to a change, see ::attClientAwareStates.
*
* \return None.
*/
/*************************************************************************************************/
void AppDbSetClientsChangeAwareState(appDbHdl_t hdl, uint8_t state);
/*************************************************************************************************/
/*!
* \brief Get device's GATT database hash.
*
* \return Pointer to database hash.
*/
/*************************************************************************************************/
uint8_t *AppDbGetDbHash(void);
/*************************************************************************************************/
/*!
* \brief Set device's GATT database hash.
*
* \param pHash GATT database hash to store.
*
* \return None.
*/
/*************************************************************************************************/
void AppDbSetDbHash(uint8_t *pHash);
/*************************************************************************************************/
/*!
* \brief Get the peer's database hash.
*
* \param hdl Database record handle.
*
* \return Pointer to database hash.
*/
/*************************************************************************************************/
uint8_t *AppDbGetPeerDbHash(appDbHdl_t hdl);
/*************************************************************************************************/
/*!
* \brief Set a new peer database hash.
*
* \param hdl Database record handle.
* \param dbHash Pointer to new hash.
*
* \return None.
*/
/*************************************************************************************************/
void AppDbSetPeerDbHash(appDbHdl_t hdl, uint8_t *dbHash);
/*************************************************************************************************/
/*!
* \brief Check if cached handles' validity are ascertained by reading the peer's database hash
*
* \param hdl Database record handle.
*
* \return \ref TRUE if peer's database hash must be read to verify handles have not changed.
*/
/*************************************************************************************************/
bool_t AppDbIsCacheCheckedByHash(appDbHdl_t hdl);
/*************************************************************************************************/
/*!
* \brief Set if cached handles' validity are determined by reading the peer's database hash.
*
* \param hdl Database record handle.
* \param cacheByHash \ref TRUE if peer's database must be read to verify cached handles.
*
* \return None.
*/
/*************************************************************************************************/
void AppDbSetCacheByHash(appDbHdl_t hdl, bool_t cacheByHash);
/*************************************************************************************************/
/*!
* \brief Get the discovery status.
*
* \param hdl Database record handle.
*
* \return Discovery status.
*/
/*************************************************************************************************/
uint8_t AppDbGetDiscStatus(appDbHdl_t hdl);
/*************************************************************************************************/
/*!
* \brief Get the discovery status.
*
* \param hdl Database record handle.
*
* \return Discovery status.
*/
/*************************************************************************************************/
uint8_t AppDbGetDiscStatus(appDbHdl_t hdl);
/*************************************************************************************************/
/*!
* \brief Set the discovery status.
*
* \param hdl Database record handle.
* \param status Discovery status.
*
* \return None.
*/
/*************************************************************************************************/
void AppDbSetDiscStatus(appDbHdl_t hdl, uint8_t status);
/*************************************************************************************************/
/*!
* \brief Get the cached handle list.
*
* \param hdl Database record handle.
*
* \return Pointer to handle list.
*/
/*************************************************************************************************/
uint16_t *AppDbGetHdlList(appDbHdl_t hdl);
/*************************************************************************************************/
/*!
* \brief Set the cached handle list.
*
* \param hdl Database record handle.
* \param pHdlList Pointer to handle list.
*
* \return None.
*/
/*************************************************************************************************/
void AppDbSetHdlList(appDbHdl_t hdl, uint16_t *pHdlList);
/*************************************************************************************************/
/*!
* \brief Get the device name.
*
* \param pLen Returned device name length.
*
* \return Pointer to UTF-8 string containing the device name or NULL if not set.
*/
/*************************************************************************************************/
char *AppDbGetDevName(uint8_t *pLen);
/*************************************************************************************************/
/*!
* \brief Set the device name.
*
* \param len Device name length.
* \param pStr UTF-8 string containing the device name.
*
* \return None.
*/
/*************************************************************************************************/
void AppDbSetDevName(uint8_t len, char *pStr);
/*************************************************************************************************/
/*!
* \brief Get address resolution attribute value read from a peer device.
*
* \param hdl Database record handle.
*
* \return TRUE if address resolution is supported in peer device. FALSE, otherwise.
*/
/*************************************************************************************************/
bool_t AppDbGetPeerAddrRes(appDbHdl_t hdl);
/*************************************************************************************************/
/*!
* \brief Set address resolution attribute value for a peer device.
*
* \param hdl Database record handle.
* \param addrRes Peer address resolution attribue value.
*
* \return None.
*/
/*************************************************************************************************/
void AppDbSetPeerAddrRes(appDbHdl_t hdl, uint8_t addrRes);
/*************************************************************************************************/
/*!
* \brief Get sign counter for a peer device.
*
* \param hdl Database record handle.
*
* \return Sign counter for peer device.
*/
/*************************************************************************************************/
uint32_t AppDbGetPeerSignCounter(appDbHdl_t hdl);
/*************************************************************************************************/
/*!
* \brief Set sign counter for a peer device.
*
* \param hdl Database record handle.
* \param signCounter Sign counter for peer device.
*
* \return None.
*/
/*************************************************************************************************/
void AppDbSetPeerSignCounter(appDbHdl_t hdl, uint32_t signCounter);
/*************************************************************************************************/
/*!
* \brief Get the peer device added to resolving list flag value.
*
* \param hdl Database record handle.
*
* \return TRUE if peer device's been added to resolving list. FALSE, otherwise.
*/
/*************************************************************************************************/
bool_t AppDbGetPeerAddedToRl(appDbHdl_t hdl);
/*************************************************************************************************/
/*!
* \brief Set the peer device added to resolving list flag to a given value.
*
* \param hdl Database record handle.
* \param peerAddedToRl Peer device added to resolving list flag value.
*
* \return None.
*/
/*************************************************************************************************/
void AppDbSetPeerAddedToRl(appDbHdl_t hdl, bool_t peerAddedToRl);
/*************************************************************************************************/
/*!
* \brief Get resolvable private address only attribute present flag for a peer device.
*
* \param hdl Database record handle.
*
* \return TRUE if RPA Only attribute is present on peer device. FALSE, otherwise.
*/
/*************************************************************************************************/
bool_t AppDbGetPeerRpao(appDbHdl_t hdl);
/*************************************************************************************************/
/*!
* \brief Set resolvable private address only attribute present flag for a peer device.
*
* \param hdl Database record handle.
* \param peerRpao Resolvable private address only attribute present flag.
*
* \return None.
*/
/*************************************************************************************************/
void AppDbSetPeerRpao(appDbHdl_t hdl, bool_t peerRpao);
/**@}*/
/*! \} */ /*! APP_FRAMEWORK_DB_API */
#ifdef __cplusplus
};
#endif
#endif /* APP_DB_H */
@@ -0,0 +1,261 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Application framework hardware interfaces.
*
* Copyright (c) 2011-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef APP_HW_H
#define APP_HW_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup APP_FRAMEWORK_HW_API
* \{ */
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! \brief Heart rate measurement structure */
typedef struct
{
uint16_t *pRrInterval; /*!< \brief Array of RR intervals */
uint8_t numIntervals; /*!< \brief Length of RR interval array */
uint16_t energyExp; /*!< \brief Energy expended value */
uint16_t heartRate; /*!< \brief Heart rate */
uint8_t flags; /*!< \brief Heart rate measurement flags */
} appHrm_t;
/*! \brief Date and time structure */
typedef struct
{
uint16_t year; /*!< \brief Year */
uint8_t month; /*!< \brief Month */
uint8_t day; /*!< \brief Day */
uint8_t hour; /*!< \brief Hour */
uint8_t min; /*!< \brief Minutes */
uint8_t sec; /*!< \brief Seconds */
} appDateTime_t;
/*! \brief Blood pressure measurement structure */
typedef struct
{
appDateTime_t timestamp; /*!< \brief Date-time */
uint16_t systolic; /*!< \brief Systolic pressure */
uint16_t diastolic; /*!< \brief Diastolic pressure */
uint16_t map; /*!< \brief Mean arterial pressure */
uint16_t pulseRate; /*!< \brief Pulse rate */
uint16_t measStatus; /*!< \brief Measurement status */
uint8_t flags; /*!< \brief Flags */
uint8_t userId; /*!< \brief User ID */
} appBpm_t;
/*! \brief Weight scale measurement structure */
typedef struct
{
appDateTime_t timestamp; /*!< \brief Date-time */
uint16_t weight; /*!< \brief Weight */
uint8_t flags; /*!< \brief Weight measurement flags */
} appWsm_t;
/*! \brief Temperature measurement structure */
typedef struct
{
appDateTime_t timestamp; /*!< \brief Date-time */
uint32_t temperature; /*!< \brief Temperature */
uint8_t flags; /*!< \brief Flags */
uint8_t tempType; /*!< \brief Temperature type */
} appTm_t;
/*! \brief Pulse Oximeter continuous measurement structure */
typedef struct
{
uint8_t flags; /*!< \brief Flags */
uint16_t spo2; /*!< \brief SpO2PR-Spot-Check - SpO2 */
uint16_t pulseRate; /*!< \brief SpO2PR-Spot-Check - Pulse Rate */
uint16_t spo2Fast; /*!< \brief SpO2PR-Spot-Check Fast - SpO2 */
uint16_t pulseRateFast; /*!< \brief SpO2PR-Spot-Check Fast - Pulse Rate */
uint16_t spo2Slow; /*!< \brief SpO2PR-Spot-Check Slow - SpO2 */
uint16_t pulseRateSlow; /*!< \brief SpO2PR-Spot-Check Slow - Pulse Rate */
uint16_t measStatus; /*!< \brief Measurement Status */
uint32_t sensorStatus; /*!< \brief Device and Sensor Status */
uint16_t pulseAmpIndex; /*!< \brief Pulse Amplitude Index */
} appPlxCm_t;
/*! \brief Pulse Oximeter spot check measurement structure */
typedef struct
{
uint8_t flags; /*!< \brief Flags */
uint16_t spo2; /*!< \brief SpO2PR-Spot-Check - SpO2 */
uint16_t pulseRate; /*!< \brief SpO2PR-Spot-Check - Pulse Rate */
appDateTime_t timestamp; /*!< \brief Timestamp */
uint16_t measStatus; /*!< \brief Measurement Status */
uint32_t sensorStatus; /*!< \brief Device and Sensor Status */
uint16_t pulseAmpIndex; /*!< \brief Pulse Amplitude Index */
} appPlxScm_t;
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/** \name App Hardware Interface
* Interface to emulated sensor of real world devices (e.g. battery, heart rate monitor,
* blood pressure sensor, etc.)
*/
/**@{*/
/*************************************************************************************************/
/*!
* \brief Read the battery level. The battery level value returned in pLevel is the
* percentage of remaining battery capacity (0-100%).
*
* \param pLevel Battery level return value.
*
* \return None.
*/
/*************************************************************************************************/
void AppHwBattRead(uint8_t *pLevel);
/*************************************************************************************************/
/*!
* \brief Set the battery level, for test purposes.
*
* \param level Battery level (0-100%).
*
* \return None.
*/
/*************************************************************************************************/
void AppHwBattTest(uint8_t level);
/*************************************************************************************************/
/*!
* \brief Perform a heart rate measurement. Return the heart rate along with any RR interval
* data.
*
* \param pHrm Heart rate measurement return value.
*
* \return None.
*/
/*************************************************************************************************/
void AppHwHrmRead(appHrm_t *pHrm);
/*************************************************************************************************/
/*!
* \brief Set the heart rate, for test purposes.
*
* \param heartRate Heart rate.
*
* \return None.
*/
/*************************************************************************************************/
void AppHwHrmTest(uint8_t heartRate);
/*************************************************************************************************/
/*!
* \brief Perform a blood pressure measurement. Return the measurement data.
*
* \param intermed TRUE if this is an intermediate measurement.
* \param pBpm Blood pressure measurement return value.
*
* \return None.
*/
/*************************************************************************************************/
void AppHwBpmRead(bool_t intermed, appBpm_t *pBpm);
/*************************************************************************************************/
/*!
* \brief Perform a weight scale measurement. Return the measurement data.
*
* \param pWsm Weight scale measurement return value.
*
* \return None.
*/
/*************************************************************************************************/
void AppHwWsmRead(appWsm_t *pWsm);
/*************************************************************************************************/
/*!
* \brief Perform a temperature measurement. Return the measurement data.
*
* \param intermed TRUE if this is an intermediate measurement.
* \param pTm Temperature measurement return value.
*
* \return None.
*/
/*************************************************************************************************/
void AppHwTmRead(bool_t intermed, appTm_t *pTm);
/*************************************************************************************************/
/*!
* \brief Set the temperature measurement units.
*
* \param units CH_TM_FLAG_UNITS_C or CH_TM_FLAG_UNITS_F.
*
* \return None.
*/
/*************************************************************************************************/
void AppHwTmSetUnits(uint8_t units);
/*************************************************************************************************/
/*!
* \brief Set the weight measurement units.
*
* \param units CH_WSM_FLAG_UNITS_KG or CH_WSM_FLAG_UNITS_LBS.
*
* \return None.
*/
/*************************************************************************************************/
void AppHwWmSetUnits(uint8_t units);
/*************************************************************************************************/
/*!
* \brief Perform a pulse oximeter measurement.
*
* \param pPlxcm Pulse Oximeter measurement return value.
*
* \return None.
*/
/*************************************************************************************************/
void AppHwPlxcmRead(appPlxCm_t *pPlxcm);
/*************************************************************************************************/
/*!
* \brief Perform a pulse oximeter spot check measurement.
*
* \param pPlxscm Pulse Oximeter measurement return value.
*
* \return None.
*/
/*************************************************************************************************/
void AppHwPlxscmRead(appPlxScm_t *pPlxscm);
/**@}*/
/*! \} */ /*! APP_FRAMEWORK_HW_API */
#ifdef __cplusplus
};
#endif
#endif /* APP_HW_H */
@@ -0,0 +1,95 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Application framework parameter database.
*
* Copyright (c) 2015-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef APP_PARAM_H
#define APP_PARAM_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup APP_FRAMEWORK_PARAM_API
* \{ */
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/** \name App Parameter Database
* Interface to read and write parameter data in a file system.
*/
/**@{*/
/*************************************************************************************************/
/*!
* \brief Initialize the parameter database.
*
* \return None.
*/
/*************************************************************************************************/
void AppParamInit(void);
/*************************************************************************************************/
/*!
* \brief Clear the parameter database.
*
* \return None.
*/
/*************************************************************************************************/
void AppParamClear(void);
/*************************************************************************************************/
/*!
* \brief Write parameter value.
*
* \param id Identifier.
* \param valueLen Value length in bytes.
* \param pValue Value data.
*
* \return Number of bytes written.
*/
/*************************************************************************************************/
uint16_t AppParamWrite(uint16_t id, uint16_t valueLen, const uint8_t *pValue);
/*************************************************************************************************/
/*!
* \brief Read parameter value.
*
* \param id Identifier.
* \param valueLen Maximum value length in bytes.
* \param pValue Storage value data.
*
* \return Number of bytes read.
*/
/*************************************************************************************************/
uint16_t AppParamRead(uint16_t id, uint16_t valueLen, uint8_t *pValue);
/**@}*/
/*! \} */ /*! APP_FRAMEWORK_PARAM_API */
#ifdef __cplusplus
};
#endif
#endif /* APP_PARAM_H */
@@ -0,0 +1,53 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief App Terminal handler.
*
* Copyright (c) 2015-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef APP_TERMINAL_H
#define APP_TERMINAL_H
/*! \addtogroup APP_FRAMEWORK_UI_API
* \{ */
/**************************************************************************************************
Function Prototypes
**************************************************************************************************/
/** \name APP Terminal Functions
* Open a terminal interface to the application.
*/
/**@{*/
/*************************************************************************************************/
/*!
* \brief Initialize terminal.
*
* \return None.
*/
/*************************************************************************************************/
void AppTerminalInit(void);
/**@}*/
/*! \} */ /*! APP_FRAMEWORK_UI_API */
#endif /* APP_TERMINAL_H */
@@ -0,0 +1,297 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Application framework user interface.
*
* Copyright (c) 2011-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef APP_UI_H
#define APP_UI_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup APP_FRAMEWORK_UI_API
* \{ */
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! \brief UI event enumeration */
enum
{
APP_UI_NONE, /*!< \brief No event */
APP_UI_RESET_CMPL, /*!< \brief Reset complete */
APP_UI_DISCOVERABLE, /*!< \brief Enter discoverable mode */
APP_UI_ADV_START, /*!< \brief Advertising started */
APP_UI_ADV_STOP, /*!< \brief Advertising stopped */
APP_UI_SCAN_START, /*!< \brief Scanning started */
APP_UI_SCAN_STOP, /*!< \brief Scanning stopped */
APP_UI_SCAN_REPORT, /*!< \brief Scan data received from peer device */
APP_UI_CONN_OPEN, /*!< \brief Connection opened */
APP_UI_CONN_CLOSE, /*!< \brief Connection closed */
APP_UI_SEC_PAIR_CMPL, /*!< \brief Pairing completed successfully */
APP_UI_SEC_PAIR_FAIL, /*!< \brief Pairing failed or other security failure */
APP_UI_SEC_ENCRYPT, /*!< \brief Connection encrypted */
APP_UI_SEC_ENCRYPT_FAIL, /*!< \brief Encryption failed */
APP_UI_PASSKEY_PROMPT, /*!< \brief Prompt user to enter passkey */
APP_UI_ALERT_CANCEL, /*!< \brief Cancel a low or high alert */
APP_UI_ALERT_LOW, /*!< \brief Low alert */
APP_UI_ALERT_HIGH, /*!< \brief High alert */
APP_UI_ADV_SET_START_IND, /*!< \brief Advertising set(s) started */
APP_UI_ADV_SET_STOP_IND, /*!< \brief Advertising set(s) stopped */
APP_UI_SCAN_REQ_RCVD_IND, /*!< \brief Scan request received */
APP_UI_EXT_SCAN_START_IND, /*!< \brief Extended scanning started */
APP_UI_EXT_SCAN_STOP_IND, /*!< \brief Extended scanning stopped */
APP_UI_PER_ADV_SET_START_IND, /*!< \brief Periodic advertising set started */
APP_UI_PER_ADV_SET_STOP_IND, /*!< \brief Periodic advertising set stopped */
APP_UI_PER_ADV_SYNC_EST_IND, /*!< \brief Periodic advertising sync established */
APP_UI_PER_ADV_SYNC_LOST_IND, /*!< \brief Periodic advertising sync lost */
APP_UI_HW_ERROR /*!< \brief Hardware error */
};
/*! \brief Button press enumeration */
enum
{
APP_UI_BTN_NONE, /*!< \brief No button press */
APP_UI_BTN_1_DOWN, /*!< \brief Button 1 on down press */
APP_UI_BTN_1_SHORT, /*!< \brief Button 1 short press */
APP_UI_BTN_1_MED, /*!< \brief Button 1 medium press */
APP_UI_BTN_1_LONG, /*!< \brief Button 1 long press */
APP_UI_BTN_1_EX_LONG, /*!< \brief Button 1 extra long press */
APP_UI_BTN_2_DOWN, /*!< \brief Button 2 on down press */
APP_UI_BTN_2_SHORT, /*!< \brief Button 2 short press */
APP_UI_BTN_2_MED, /*!< \brief Button 2 medium press */
APP_UI_BTN_2_LONG, /*!< \brief Button 2 long press */
APP_UI_BTN_2_EX_LONG /*!< \brief Button 2 extra long press */
};
/*! \brief LED values */
#define APP_UI_LED_NONE 0x00 /*!< \brief No LED */
#define APP_UI_LED_1 0x01 /*!< \brief LED 1 */
#define APP_UI_LED_2 0x02 /*!< \brief LED 2 */
#define APP_UI_LED_3 0x04 /*!< \brief LED 3 */
#define APP_UI_LED_4 0x08 /*!< \brief LED 4 */
#define APP_UI_LED_WRAP 0xFF /*!< \brief Wrap to beginning of sequence */
/*! \brief Sound tone value for wrap/repeat */
#define APP_UI_SOUND_WRAP 0xFFFF
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! \brief Button press callback */
typedef void (*appUiBtnCback_t)(uint8_t btn);
/*! \brief Action event callback */
typedef void (*appUiActionCback_t)(uint8_t event);
/*! \brief Button Poll callback */
typedef void (*appUiBtnPollCback_t)(void);
/*! \brief Print callback */
typedef void (*appUiPrintFunc_t)(const char *txt);
/*! \brief Sound data structure */
typedef struct
{
uint16_t tone; /*!< \brief Sound tone in Hz. Use 0 for silence. */
uint16_t duration; /*!< \brief Sound duration in milliseconds */
} appUiSound_t;
/*! \brief LED data structure */
typedef struct
{
uint8_t led; /*!< \brief LED to control */
uint8_t state; /*!< \brief On or off */
uint16_t duration; /*!< \brief duration in milliseconds */
} appUiLed_t;
/*! \brief Callback structure */
typedef struct
{
appUiBtnCback_t btnCback; /*!< \brief Called when button pressed */
appUiActionCback_t actionCback; /*!< \brief Called when action event received */
appUiBtnPollCback_t btnPollCback; /*!< \brief Called to poll button hardware */
} appUiCback_t;
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/** \name APP User Interface
* Commands that may be sent via terminal to the application.
*/
/**@{*/
/*************************************************************************************************/
/*!
* \brief Perform a user interface action based on the event value passed to the function.
*
* \param event User interface event value.
*
* \return None.
*/
/*************************************************************************************************/
void AppUiAction(uint8_t event);
/*************************************************************************************************/
/*!
* \brief Display a passkey.
*
* \param passkey Passkey to display.
*
* \return None.
*/
/*************************************************************************************************/
void AppUiDisplayPasskey(uint32_t passkey);
/*************************************************************************************************/
/*!
* \brief Display a confirmation value.
*
* \param confirm Confirm value to display.
*
* \return None.
*/
/*************************************************************************************************/
void AppUiDisplayConfirmValue(uint32_t confirm);
/*************************************************************************************************/
/*!
* \brief Display an RSSI value.
*
* \param rssi Rssi value to display.
*
* \return None.
*/
/*************************************************************************************************/
void AppUiDisplayRssi(int8_t rssi);
/*************************************************************************************************/
/*!
* \brief Register a callback function to receive button presses.
*
* \param btnCback Callback function.
*
* \return None.
*
* \note Registered by application to receive button events
*/
/*************************************************************************************************/
void AppUiBtnRegister(appUiBtnCback_t btnCback);
/*************************************************************************************************/
/*!
* \brief Register a callback function to receive action events.
*
* \param actionCback Callback function.
*
* \return None.
*
* \note Registered by platform
*/
/*************************************************************************************************/
void AppUiActionRegister(appUiActionCback_t actionCback);
/*************************************************************************************************/
/*!
* \brief Register a callback function to receive APP_BTN_POLL_IND events.
*
* \param btnPollCback Callback function.
*
* \return None.
*
* \note Registered by platform
*/
/*************************************************************************************************/
void AppUiBtnPollRegister(appUiBtnPollCback_t btnPollCback);
/*************************************************************************************************/
/*!
* \brief Handle a hardware button press. This function is called to handle WSF
* event APP_BTN_DOWN_EVT.
*
* \return None.
*/
/*************************************************************************************************/
void AppUiBtnPressed(void);
/*************************************************************************************************/
/*!
* \brief Play a sound.
*
* \param pSound Pointer to sound tone/duration array.
*
* \return None.
*/
/*************************************************************************************************/
void AppUiSoundPlay(const appUiSound_t *pSound);
/*************************************************************************************************/
/*!
* \brief Stop the sound that is currently playing.
*
* \return None.
*/
/*************************************************************************************************/
void AppUiSoundStop(void);
/*************************************************************************************************/
/*!
* \brief Start LED blinking.
*
* \param pLed Pointer to LED data structure.
*
* \return None.
*/
/*************************************************************************************************/
void AppUiLedStart(const appUiLed_t *pLed);
/*************************************************************************************************/
/*!
* \brief Stop LED blinking.
*
* \return None.
*/
/*************************************************************************************************/
void AppUiLedStop(void);
/*************************************************************************************************/
/*!
* \brief Button test function-- for test purposes only.
*
* \param btn button press
* \return None.
*/
/*************************************************************************************************/
void AppUiBtnTest(uint8_t btn);
/**@}*/
/*! \} */ /*! APP_FRAMEWORK_UI_API */
#ifdef __cplusplus
};
#endif
#endif /* APP_UI_H */
@@ -0,0 +1,624 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief User Interface API.
*
* Copyright (c) 2017-2019 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef UI_API_H
#define UI_API_H
#include "wsf_os.h"
#include "app_ui.h"
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! \brief Display types */
#define UI_DISPLAY_CONSOLE 0 /*!< Console display type */
#define UI_DISPLAY_LCD 1 /*!< LCD display type */
#define UI_DISPLAY_MAX 2 /*!< Number of display types */
/*! \brief LCD configuration */
#define LCD_NUM_LINES 4 /*!< Number of lines on the LCD */
#define LCD_LINE_LEN 20 /*!< Number of characters per line on the LCD */
#define LCD_EXT_LINE_LEN 35 /*!< Number of characters for extended text fields */
#define LCD_SEL_COL_WIDTH 2 /*!< Number of characters for line selection icon */
/*! \brief Dialog types */
#define UI_DLG_TYPE_INPUT_NUM 0 /*!< Type of Dialog - Numeric input */
#define UI_DLG_TYPE_INPUT_ALPHANUM 1 /*!< Type of Dialog - Alpha numeric input */
#define UI_DLG_TYPE_INPUT_SELECT 2 /*!< Type of Dialog - List of selections */
/*! \brief UI events */
#define UI_SPLASH_TIMER_IND 1 /*!< Splash screen timer expired */
#define UI_SCROLL_TIMER_IND 2 /*!< Tick timer expired */
#define UI_DURATION_TIMER_IND 3 /*!< Running dialog duration timer expired */
#define UI_BUTTON_UP_IND 4 /*!< Button up pressed */
#define UI_BUTTON_DOWN_IND 5 /*!< Button down pressed */
#define UI_BUTTON_SELECT_IND 6 /*!< Button selected pressed */
#define UI_BUTTON_WAKE_IND 7 /*!< Wake button pressed */
#define HCI_DEV_CMD_CNT_TIMER_IND 8 /*!< HCI Device cmd/evt counter timer */
#define UI_RESET_TIMER_IND 9 /*!< Timer to wait for DM reset to complete */
#define UI_SLEEP_TIMER_IND 10 /*!< Timer to put application to sleep */
#define UI_STATISTICS_TIMER_IND 11 /*!< Timer to poll and display app statistics */
/*! \brief User key inputs */
#define UI_INPUT_0 0 /*!< '0' key pressed - For console only */
#define UI_INPUT_1 1 /*!< '1' key pressed - For console only */
#define UI_INPUT_2 2 /*!< '2' key pressed - For console only */
#define UI_INPUT_3 3 /*!< '3' key pressed - For console only */
#define UI_INPUT_4 4 /*!< '4' key pressed - For console only */
#define UI_INPUT_5 5 /*!< '5' key pressed - For console only */
#define UI_INPUT_6 6 /*!< '6' key pressed - For console only */
#define UI_INPUT_7 7 /*!< '7' key pressed - For console only */
#define UI_INPUT_8 8 /*!< '8' key pressed - For console only */
#define UI_INPUT_9 9 /*!< '9' key pressed - For console only */
#define UI_INPUT_BTN_UP 10 /*!< Up key pressed - For LCD only */
#define UI_INPUT_BTN_DOWN 11 /*!< Down key pressed - For LCD only */
#define UI_INPUT_BTN_SELECT 12 /*!< Select key pressed - For LCD only */
/*! \brief Screen types */
#define UI_SCREEN_SPLASH 0 /*!< Splash screen type */
#define UI_SCREEN_MENU 1 /*!< Menu screen type */
#define UI_SCREEN_DIALOG 2 /*!< Dialog screen type */
#define UI_SCREEN_INVALID 3 /*!< Invalid screen type */
/*! \brief Message Button Macros */
#define UI_MESSAGE_OK 0 /*!< OK button type */
#define UI_MESSAGE_EXIT 1 /*!< Exit button type */
#define UI_MESSAGE_ABORT 2 /*!< Abort button type */
#define UI_MESSAGE_STOP 3 /*!< Stop button type */
/*! \brief Text format types */
#define UI_FORMAT_SECONDS 0 /*!< Seconds foramt */
#define UI_FORMAT_MILLISECONDS 1 /*!< Milliseconds format */
#define UI_FORMAT_MBS 2 /*!< Mega bits per second format */
#define UI_FORMAT_INTEGER 3 /*!< Integer format */
#define UI_FORMAT_TIME 4 /*!< Time format */
#define UI_FORMAT_BD_ADDR 5 /*!< BLE device address */
#define UI_FORMAT_MAC154_ADDR 6 /*!< 15.4 MAC device address */
#define UI_FORMAT_MESH_UUID 7 /*!< Mesh device UUID */
#define UI_FORMAT_VERSION 8 /*!< Version code */
#define UI_FORMAT_HEX_BYTE 9 /*!< Byte in hex */
/*! \brief Text formatting lengths */
#define UI_MAX_A2HS_LEN 16 /* Max length of array2HexStr conversion. */
#define UI_BD_ADDR_LEN 6 /* BLE address length. */
#define UI_MAC_ADDR_LEN 8 /* 802.15.4 MAC address length. */
#define UI_UUID_ADDR_LEN 16 /* Mesh device UUID length. */
/*! \brief Menu open selection */
#define UI_MENU_ITEM_ON_OPEN 0 /*!< Event to selection handler when menu opens */
/*************************************************************************************************/
/*!
* \brief Datatype for menu item select callback function
*
* \param pMenu Pointer to the active menu object.
* \param selection User selection.
*
* \return None
*/
/*************************************************************************************************/
typedef void (*UiSelCback_t)(const void *pMenu, uint8_t selection);
/*************************************************************************************************/
/*!
* \brief Datatype for dialog item select callback function
*
* \param pDialog Pointer to the active dialog object.
* \param selection User selection.
*
* \return None
*/
/*************************************************************************************************/
typedef void (*UiDialogSelCback_t)(const void *pDialog, uint8_t selection);
/*************************************************************************************************/
/*!
* \brief Datatype for the LCD scrolling item text timer callback function
*
* \return None
*/
/*************************************************************************************************/
typedef void (*UiScrollCback_t)(void);
/*************************************************************************************************/
/*!
* \brief Datatype for processing event callback functions
*
* \param event Ebent identifier.
*
* \return None
*/
/*************************************************************************************************/
typedef void (*UiProcEvent_t)(uint8_t event);
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! \brief Pointer to a const string */
typedef const char *constStr;
/*! \brief Screen type */
typedef uint8_t UiScreenType_t;
/*! \brief Input type */
typedef uint8_t UiInputType_t;
/*! \brief Display object base type */
typedef struct
{
void *pParentMenu; /*!< Parent menu */
void *pCtx; /*!< Opaque context pointer */
} UiBase_t;
/*! \brief Display menu object */
typedef struct
{
UiBase_t base; /*!< Base object */
const char *pTitle; /*!< Title of the menu */
uint8_t numItems; /*!< Size of pItems in number of strings */
uint8_t highlight; /*!< Index of pItems highlighted on an LCD display */
UiSelCback_t selectCback; /*!< Callback called when a menu item is selected */
constStr *pItems; /*!< Array of strings containing menu items */
uint32_t readOnlyMask; /*!< Read only mask. If bit is set, menu item at index is RO */
} UiMenu_t;
/*! \brief Display splash screen object */
typedef struct
{
const char *pAppName; /*!< Name of the application */
const char *pAppVer; /*!< Version of the application */
const char *pCopyright; /*!< Copyright string */
uint16_t durMs; /*!< Time in milliseconds splash screen is displayed */
} UiSplashScreen_t;
/*! \brief Display dialog object */
typedef struct
{
UiBase_t base; /*!< Base object */
const char *pTitle; /*!< Title of the dialog */
const char *pMsg; /*!< Message displayed on the dialog */
uint8_t type; /*!< Type of dialog (UI_DLG_TYPE_INPUT_NUM, UI_DLG_TYPE_INPUT_SELECT, ...) */
char *pEntry; /*!< Pointer to char array containing input from a user */
uint8_t entryMaxLen; /*!< Size of pEntry in bytes */
uint8_t highlight; /*!< Index of pSelectItems highlighted on an LCD display */
UiDialogSelCback_t selectCback; /*!< Callback called when a dialog item is selected */
uint8_t numSelectItems; /*!< Size of pSelectItems in number of strings */
constStr *pSelectItems; /*!< Array of strings containing dialog select items */
} UiDialog_t;
/*! \brief Power supply mode. */
typedef enum
{
UI_PS_MODE_BATT, /*!< Battery mode. */
UI_PS_MODE_LINE, /*!< USB line mode. */
} UiPsMode_t;
/*! \brief Display Splash Screen action function */
typedef void (*UiDispSplash_t)(const UiSplashScreen_t *pSplash);
/*! \brief Display Splash Screen action function */
typedef void (*UiDispMenu_t)(const UiMenu_t *pMenu);
/*! \brief Display Splash Screen action function */
typedef void (*UiDispDialog_t)(const UiDialog_t *pDialog);
/*! \brief Process key press from the user */
typedef void (*UiKeyPress_t)(uint8_t input);
/*! \brief Table of display action functions */
typedef struct
{
UiDispSplash_t displaySplash; /*!< Display splash screen action function */
UiDispMenu_t displayMenu; /*!< Display menu screen action function */
UiDispDialog_t displayDialog; /*!< Display dialog screen action function */
UiKeyPress_t keyPress; /*!< Process key input from user action function */
} UiActionTbl_t;
/*! \brief UI Control Block */
typedef struct
{
wsfHandlerId_t handlerId; /*!< UI task handler identifier */
UiActionTbl_t uiActionTbl[UI_DISPLAY_MAX]; /*!< Action function table */
const UiMenu_t *pMainMenu; /*!< Main menu */
const UiBase_t *pActiveScreen; /*!< Pointer to the active screen */
UiScreenType_t activeScreenType; /*!< Type of active screen (splash, menu, or dialog) */
UiDialogSelCback_t durationDlgCback; /*!< Callback called when the duration dialog closes */
UiDialogSelCback_t messageDlgCback; /*!< Callback called when the message dialog closes */
UiScrollCback_t scrollCback; /*!< Callback called on scroll timer timeout */
} UiCb_t;
/*! \brief External declaration of display control block */
extern UiCb_t UiCb;
/**************************************************************************************************
Function API
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Display a menu on the active UI
*
* \param pMenu Pointer to the menu object to display.
*
* \return None
*/
/*************************************************************************************************/
void UiLoadMenu(const UiMenu_t *pMenu);
/*************************************************************************************************/
/*!
* \brief Display a dialog on the active UI
*
* \param pDialog Pointer to the dialog object to display.
*
* \return None
*/
/*************************************************************************************************/
void UiLoadDialog(const UiDialog_t *pDialog);
/*************************************************************************************************/
/*!
* \brief Start the scroll timer
*
* \param scrollCback Callback called on timer timeout
* \param ms Period between timeout in milliseconds
*
* \return None
*/
/*************************************************************************************************/
void UiScrollTimerStart(const UiScrollCback_t scrollCback, uint16_t ms);
/*************************************************************************************************/
/*!
* \brief Stop the scroll timer
*
* \return None
*/
/*************************************************************************************************/
void UiScrollTimerStop(void);
/*************************************************************************************************/
/*!
* \brief Called when the user selects an item in a menu or dialog
*
* \param selection Number of menu or dialog item selected by user {1 ... numSelectItems}
*
* \return None
*/
/*************************************************************************************************/
void UiSelection(uint8_t selection);
/*************************************************************************************************/
/*!
* \brief Refresh the active menu or dialog
*
* \return None
*/
/*************************************************************************************************/
void UiRefresh(void);
/*************************************************************************************************/
/*!
* \brief Copy a string and return a pointer to the end of the new string.
*
* \param pBuf String buffer.
* \param pStr String to copy.
*
* \return Length of the formatted string.
*/
/*************************************************************************************************/
uint8_t UiCpyStr(char *pBuf, char *pStr);
/*************************************************************************************************/
/*!
* \brief Append a formatted value to a string.
*
* \param pBuf String buffer.
* \param value Value to format.
* \param format Type of formatting to use.
*
* \return Pointer to the end of the formatted string.
*/
/*************************************************************************************************/
char *UiFormatValue(char *pBuf, uint32_t value, uint8_t format);
/*************************************************************************************************/
/*!
* \brief Append a formatted array of values to a string.
*
* \param pBuf String buffer.
* \param pValue Pointer to array to format.
* \param format Type of formatting to use.
*
* \return Pointer to the end of the formatted string.
*/
/*************************************************************************************************/
char *UiFormatArray(char *pBuf, uint8_t *pValue, uint8_t format);
/*************************************************************************************************/
/*!
* \brief Initialize the UI.
*
* \param pSplash Splash screen to display at startup.
* \param pMenu Main Menu.
*
* \return None
*/
/*************************************************************************************************/
void UiInit(const UiSplashScreen_t *pSplash, const UiMenu_t *pMenu);
/*************************************************************************************************/
/*!
* \brief Register a display.
*
* \param actionTbl Table of action functions.
* \param id Display identifier.
*
* \return None
*/
/*************************************************************************************************/
void UiRegisterDisplay(UiActionTbl_t actionTbl, uint8_t id);
/*************************************************************************************************/
/*!
* \brief Initialize the Console Display
*
* \return None
*/
/*************************************************************************************************/
void UiConsoleInit(void);
/*************************************************************************************************/
/*!
* \brief Initialize the LCD Display
*
* \return None
*/
/*************************************************************************************************/
void UiLcdInit(void);
/*************************************************************************************************/
/*!
* \brief Display a dialog that shows the amount of time the application has been running
* and a selectable dialog item to exit the application.
*
* \param pTitle Title for the dialog
* \param pParent Parent menu to load after running dialog exits
* \param cback Callback called when dialog exits
*
* \return None
*/
/*************************************************************************************************/
void UiLoadDurationDialog(const char *pTitle, void *pParent, UiDialogSelCback_t cback);
/*************************************************************************************************/
/*!
* \brief Display a message dialog.
*
* \param pTitle Title for the dialog
* \param pMsg Message to display
* \param pExitBtn Index for the confirm ("OK", "Exit", "Abort", etc...) button (See Macros)
* \param pParent Parent menu to load after running dialog exits
* \param cback Callback called when dialog exits
*
* \return None
*/
/*************************************************************************************************/
void UiLoadMessageDialog(const char *pTitle, const char *pMsg, uint8_t pExitBtn, void *pParent, UiDialogSelCback_t cback);
/*************************************************************************************************/
/*!
* \brief Called to notify the UI subsystem of an event
*
* \param event UI Event.
*
* \return None
*/
/*************************************************************************************************/
void UiProcEvent(uint8_t event);
/*************************************************************************************************/
/*!
* \brief Write a line on the LCD
*
* \param line Line number
* \param pLine String with text to write to LCD.
*
* \return None
*/
/*************************************************************************************************/
void UiLcdWriteLine(uint8_t line, const char *pLine);
/*************************************************************************************************/
/*!
* \brief Flush the contents of the LCD buffer to the display
*
* \return None
*/
/*************************************************************************************************/
void UiLcdFlush(void);
/*************************************************************************************************/
/*!
* \brief Set flag UiDataPrepared to TRUE
*
* \return None
*/
/*************************************************************************************************/
void UiLcdSetDataPrepared(void);
/*************************************************************************************************/
/*!
* \brief Print a string to the console
*
* \param pLine String with text to print
*
* \return None
*/
/*************************************************************************************************/
void UiConsolePrint(const char *pLine);
/*************************************************************************************************/
/*!
* \brief Print a string to the console followed by a new line
*
* \param pLine String with text to print
*
* \return None
*/
/*************************************************************************************************/
void UiConsolePrintLn(const char *pLine);
/*************************************************************************************************/
/*!
* \brief Flush the contents of the Console buffer to the display
*
* \return None
*/
/*************************************************************************************************/
void UiConsoleFlush(void);
/*************************************************************************************************/
/*!
* \brief Start the time in milliseconds until a UI Timer expires.
*
* \param event Event to pass to UiProcEvent on timer expiration.
* \param ms Time in milliseconds until timer expiration.
*
* \return None.
*/
/*************************************************************************************************/
void UiTimerStart(uint8_t event, uint32_t ms);
/*************************************************************************************************/
/*!
* \brief Stop a UI timer.
*
* \param event UI timer event.
*
* \return None.
*/
/*************************************************************************************************/
void UiTimerStop(uint8_t event);
/*************************************************************************************************/
/*!
* \brief Initialize the UI Timer subsystem.
*
* \return None.
*/
/*************************************************************************************************/
void UiTimerInit(void);
/*************************************************************************************************/
/*!
* \brief Called to process user input.
*
* \param input Input from user
*
* \return None
*/
/*************************************************************************************************/
void UiProcessUserInput(uint8_t input);
/*************************************************************************************************/
/*!
* \brief Called to process user input from a PC keyboard.
*
* \param ch input
*
* \return None
*/
/*************************************************************************************************/
void UiProcessKeyboardInput(uint8_t ch);
/*************************************************************************************************/
/*!
* \brief Register a callback function to receive UI events
*
* \param cback Callback function to receive events
*
* \return None
*/
/*************************************************************************************************/
void UiRegisterAppEvtCback(UiProcEvent_t cback);
/*************************************************************************************************/
/*!
* \brief Initialize the main menu
*
* \return None.
*/
/*************************************************************************************************/
void MenuMainInit(void);
/*************************************************************************************************/
/*!
* \brief Initialize About Menu.
*
* \return None.
*/
/*************************************************************************************************/
void MenuAboutInit(void);
/*************************************************************************************************/
/*!
* \brief Get platform boot strap state.
*
* \param pin GPIO pin.
*
* \return Enable automation or not.
*/
/*************************************************************************************************/
bool_t UiPlatformGetBootStrapConfig(uint8_t pin);
/*************************************************************************************************/
/*!
* \brief Get platform power supply mode.
*
* \return Power supply mode.
*/
/*************************************************************************************************/
UiPsMode_t UiPlatformGetPowerSupplyMode(void);
/*************************************************************************************************/
/*!
* \brief Get the number of milliseconds since the device was started
*
* \return Time in ms
*/
/*************************************************************************************************/
uint32_t UiPlatformGetTime(void);
#ifdef __cplusplus
}
#endif
#endif /* UI_API_H */