hornet.h Header File
hornet.h
is the standard header file. It shall be included at the top of every C file, as the first #include
item.
#include "hornet.h"
Developer’s Responsibilities
For every firmware, developer is responsible for providing two header files:
"hornet_arch.h"
"hornet_device.h"
Those two files are referenced in hornet.h
. They shall be placed within a include search path option (-I).
hornet_arch.h
"hornet_arch.h"
define following symbols:
#define HORNET_ARCH_MCU
- This is a MCU build.#define HORNET_ARCH_CC2538
or#define HORNET_ARCH_NRF52840
- The MCU type.#define HORNET_DEVICE_TYPE
- The device type,HORNET_ROUTER
- A REED (Router Enabled End-Device). A device that can switch between router and end-device role on the fly.HORNET_RFD
- A Reduced Function Device, i.e., a sleepy device on battery.#define HORNET_ARCH_MAX_SLEEP_SECONDS
- Optional. Usually sround 8 (in seconds). Default is 8 if not provided.#define HORNET_ARCH_MAX_REJOIN_RETRY_SECONDS
- Optional. Default is 8 * 3600 = 8 hours. It prevents batter ydrain results from constant join/rejoin if there is not network. User pressing a button will trigger immediate join/rejoin.
- Other optional symbols
#define NWK_MAX_BIND_DEVICE
- Maximum bound devices. Default is 64.#define NWK_MAX_BIND_ENTRY
- Maximum bound entries, i.e., all bound endpoints. Default is 256.
Delow is an example:
#define HORNET_ARCH_NRF52840
#define HORNET_ARCH_MCU
#define HORNET_DEVICE_TYPE HORNET_ROUTER
#define HORNET_DISABLE_WATCHDOG
#define HORNET_USB_SERIAL 0
#define LIBERTAS_CLUSTER_LIB_APP_SUPPORT
#define LIBERTAS_CLUSTERS_DECLARE_ALL
hornet_device.h
"hornet_device.h"
includes device hardware specific configurations. Below is an example:
#define USE_HORNET_CLUSTER_LIB
// Buttons
#define TOTAL_BUTTONS (1)
// Buttons
#include "devices/nrf52840/dongle/flash_memory_map_device.h"
#define HORNET_DISABLE_WATCHDOG
#define MSP_STACK_BYTES (2048)
#define HORNET_ARCH_MAX_PWR_STATE (PM_STATE_IDLE)
#define LIBERTAS_APP_ENDPOINT_LOW (64)
#define LIBERTAS_APP_ENDPOINT_HIGH (253)
#define HORNET_APP_ENDPOINT_ENGINE (254)
#ifdef QW_DEBUG
#ifndef HORNET_USB_DEBUG
#define HORNET_UART_DEBUG 0
#define UART0_TX_PORT (1)
#define UART0_TX_PIN (13)
#define UART0_RX_PORT (1)
#define UART0_RX_PIN (15)
#define UART0_CONF_BAUD_RATE 30801920
#define UART_INSTANCE_COUNT (1)
#endif //!HORNET_USB_DEBUG
#endif //QW_DEBUG
Memory Map
"hornet_device.h"
must include a memory map definition. For example, the following is the memory map file for nRF52840 dongle.
#include "devices/nrf52840/dongle/flash_memory_map_device.h"
The floowing symbols must be defined.
#define FLASH_MCU_DATA_ADDR
- The flash address of “Hornet Device MCU data”.#define FLASH_PAGE_SIZE_BITS
- 11 (2KB) for TICC2538, 12 (4KB) for nRF52840.#define FLASH_STORAGE_START_ADDRESS
- The start address of Hornet flash storage, including “Flash DB” and “Flash Counters” (see below).#FLASH_DB_STORAGE_PAGES
- “Flash DB” size. Note the “Flash DB” must start with theFLASH_STORAGE_START_ADDRESS
, followed by counter pages.#define HORNET_ARCH_FLASH_COUNTER
- Shall be defined unless there is FRAM memory.#define FLASH_HORNET_COUNTER_NWK_START
#define FLASH_HORNET_COUNTER_APS_START
#define FLASH_HORNET_COUNTER_NWK_PAGES
#define FLASH_HORNET_COUNTER_APS_PAGES
#define HORNET_ARCH_FRAM
- If FRAM is used, counters are stored in FRAM instead of flash. Read__nwk_interal.h
for FRAM counter address definitions.
Please note,
FLASH_STORAGE_START_ADDRESS
must be the same asstorage_addr
in “Hornet Device MCU data”.- Sum of
FLASH_DB_STORAGE_PAGES
,FLASH_HORNET_COUNTER_NWK_PAGES
andFLASH_HORNET_COUNTER_APS_PAGES
must be the same asstorage_size
in “Hornet Device MCU data”.- “Flash DB” and flash counters are all flash storages managed by Hornet. If FRAM is used, flash counter pages is not used.