Fixed compile errors and made examples compile

This commit is contained in:
Edvard Pettersen 2018-07-26 11:56:27 +02:00
parent 45287759c2
commit 844f01de35
37 changed files with 668 additions and 585 deletions

View File

@ -350,7 +350,7 @@
* \brief Enable or disable SPI driver.
*/
#ifndef TI_SPI_CONF_ENABLE
#define TI_SPI_CONF_ENABLE 0
#define TI_SPI_CONF_ENABLE 1
#endif
/**
@ -371,7 +371,7 @@
* \brief Enable or disable I2C driver.
*/
#ifndef TI_I2C_CONF_ENABLE
#define TI_I2C_CONF_ENABLE 0
#define TI_I2C_CONF_ENABLE 1
#endif
/**
@ -439,7 +439,7 @@
#elif (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X2_CC26X2)
/* CC13x0/CC26x0 only has two SPI interface: SPI0 and SPI1. */
#define SPI_CONF_CONTROLLER_COUNT (SPI0_ENABLED + SPI1_IS_ENABLED)
#define SPI_CONF_CONTROLLER_COUNT (SPI0_IS_ENABLED + SPI1_IS_ENABLED)
#endif /* DeviceFamily_PARENT */

View File

@ -43,7 +43,7 @@ extern RF_Mode rf_ble_mode;
/*---------------------------------------------------------------------------*/
/* RF Core API commands */
extern rfc_CMD_RADIO_SETUP_t rf_ble_cmd_radio_setup;
extern rfc_CMD_FS_t rf_ble_cmd_fs;
extern rfc_bleAdvPar_t rf_ble_adv_par;
extern rfc_CMD_BLE_ADV_NC_t rf_ble_cmd_ble_adv_nc;
/*---------------------------------------------------------------------------*/
/* RF Core API Overrides */

View File

@ -122,7 +122,7 @@ uint32_t rf_ble_overrides_coded[] CC_ALIGN(4) =
};
/*---------------------------------------------------------------------------*/
/* CMD_BLE5_RADIO_SETUP: Bluetooth 5 Radio Setup Command for all PHYs */
rfc_CMD_BLE5_RADIO_SETUP_t RF_cmdBle5RadioSetup =
rfc_CMD_BLE5_RADIO_SETUP_t rf_ble_cmd_radio_setup =
{
.commandNo = CMD_BLE5_RADIO_SETUP,
.status = IDLE,
@ -148,8 +148,8 @@ rfc_CMD_BLE5_RADIO_SETUP_t RF_cmdBle5RadioSetup =
.pRegOverrideCoded = rf_ble_overrides_coded,
};
/*---------------------------------------------------------------------------*/
/* Structure for CMD_BLE5_ADV_AUX.pParams */
rfc_ble5AdvAuxPar_t rf_ble5_adv_aux_par =
/* Structure for CMD_BLE5_ADV_NC.pParams */
rfc_bleAdvPar_t rf_ble_adv_par =
{
.pRxQ = 0,
.rxConfig.bAutoFlushIgnored = 0x0,
@ -162,32 +162,36 @@ rfc_ble5AdvAuxPar_t rf_ble5_adv_aux_par =
.rxConfig.bAppendTimestamp = 0x0,
.advConfig.advFilterPolicy = 0x0,
.advConfig.deviceAddrType = 0x0,
.advConfig.targetAddrType = 0x0,
.advConfig.peerAddrType = 0x0,
.advConfig.bStrictLenFilter = 0x0,
.advConfig.bDirected = 0x0,
.advConfig.privIgnMode = 0x0,
.advConfig.rpaMode = 0x0,
.__dummy0 = 0x00,
.auxPtrTargetType = 0x00,
.auxPtrTargetTime = 0x00000000,
.pAdvPkt = 0,
.pRspPkt = 0,
.advLen = 0x18,
.scanRspLen = 0x00,
.pAdvData = 0,
.pScanRspData = 0,
.pDeviceAddress = 0,
.pWhiteList = 0,
.__dummy0 = 0x0000,
.__dummy1 = 0x00,
.endTrigger.triggerType = TRIG_NEVER,
.endTrigger.bEnaCmd = 0x0,
.endTrigger.triggerNo = 0x0,
.endTrigger.pastTrig = 0x0,
.endTime = 0x00000000,
};
/*---------------------------------------------------------------------------*/
/* CMD_BLE5_ADV_AUX: Bluetooth 5 Secondary Channel Advertiser Command */
rfc_CMD_BLE5_ADV_AUX_t rf_cmd_ble5_adv_aux =
/* CMD_BLE5_ADV_NC: Bluetooth 5 Non-Connectable Advertiser Command */
rfc_CMD_BLE5_ADV_NC_t rf_ble_cmd_ble_adv_nc =
{
.commandNo = CMD_BLE5_ADV_AUX,
.status = IDLE,
.pNextOp = 0,
.commandNo = 0x182D,
.status = 0x0000,
.pNextOp = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx
.startTime = 0x00000000,
.startTrigger.triggerType = TRIG_NOW,
.startTrigger.triggerType = 0x0,
.startTrigger.bEnaCmd = 0x0,
.startTrigger.triggerNo = 0x0,
.startTrigger.pastTrig = 0x0,
.condition.rule = COND_NEVER,
.condition.rule = 0x1,
.condition.nSkip = 0x0,
.channel = 0x8C,
.whitening.init = 0x51,
@ -196,8 +200,8 @@ rfc_CMD_BLE5_ADV_AUX_t rf_cmd_ble5_adv_aux =
.phyMode.coding = 0x0,
.rangeDelay = 0x00,
.txPower = 0x0000,
.pParams = &rf_ble5_adv_aux_par,
.pOutput = 0,
.pParams = &rf_ble_adv_par,
.pOutput = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx
.tx20Power = 0x00000000,
};
/*---------------------------------------------------------------------------*/

View File

@ -39,18 +39,18 @@
#include <ti/drivers/rf/RF.h>
/*---------------------------------------------------------------------------*/
/* TI-RTOS RF Mode Object */
extern RF_Mode rf_ble_mode;
extern RF_Mode rf_ble_mode;
/*---------------------------------------------------------------------------*/
/* RF Core API commands */
extern rfc_CMD_BLE5_RADIO_SETUP_t rf_cmd_ble5_radio_setup;
extern rfc_ble5AdvAuxPar_t rf_ble5_adv_aux_par;
extern rfc_CMD_BLE5_ADV_AUX_t rf_cmd_ble5_adv_aux;
extern rfc_CMD_BLE5_RADIO_SETUP_t rf_ble_cmd_radio_setup;
extern rfc_bleAdvPar_t rf_ble_adv_par;
extern rfc_CMD_BLE5_ADV_NC_t rf_ble_cmd_ble_adv_nc;
/*---------------------------------------------------------------------------*/
/* RF Core API Overrides */
extern uint32_t rf_ble_overrides_common[];
extern uint32_t rf_ble_overrides_1mbps[];
extern uint32_t rf_ble_overrides_2mbps[];
extern uint32_t rf_ble_overrides_coded[];
extern uint32_t rf_ble_overrides_common[];
extern uint32_t rf_ble_overrides_1mbps[];
extern uint32_t rf_ble_overrides_2mbps[];
extern uint32_t rf_ble_overrides_coded[];
/*---------------------------------------------------------------------------*/
#endif /* BLE_SETTINGS_H_ */
/*---------------------------------------------------------------------------*/

View File

@ -52,9 +52,10 @@
#include <ti/drivers/rf/RF.h>
/*---------------------------------------------------------------------------*/
#include "rf/rf.h"
#include "rf/sched.h"
#include "rf/ble-addr.h"
#include "rf/ble-beacond.h"
#include "rf/tx-power.h"
#include "rf/settings.h"
/*---------------------------------------------------------------------------*/
#include <stdbool.h>
@ -75,9 +76,9 @@ typedef enum {
BLE_ADV_CHANNEL_38 = (1 << 1),
BLE_ADV_CHANNEL_39 = (1 << 2),
BLE_ADV_CHANNEL_MASK = (BLE_ADV_CHANNEL_37 |
BLE_ADV_CHANNEL_38 |
BLE_ADV_CHANNEL_39),
BLE_ADV_CHANNEL_ALL = (BLE_ADV_CHANNEL_37 |
BLE_ADV_CHANNEL_38 |
BLE_ADV_CHANNEL_39),
} ble_adv_channel_t;
#define BLE_ADV_CHANNEL_MIN 37
@ -133,9 +134,9 @@ rf_ble_beacond_init(void)
/* Should immediately turn off radio if possible */
rf_params.nInactivityTimeout = 0;
ble_beacond.handle = ble_open(&rf_params);
ble_beacond.rf_handle = ble_open(&rf_params);
if(ble_beacond.handle == NULL) {
if(ble_beacond.rf_handle == NULL) {
return RF_BLE_BEACOND_ERROR;
}
@ -143,28 +144,39 @@ rf_ble_beacond_init(void)
}
/*---------------------------------------------------------------------------*/
rf_ble_beacond_result_t
rf_ble_beacond_start(clock_time_t interval, const char *name)
rf_ble_beacond_config(clock_time_t interval, const char *name)
{
if(interval == 0) {
return RF_BLE_BEACOND_ERROR;
rf_ble_beacond_result_t res;
res = RF_BLE_BEACOND_ERROR;
if(interval > 0) {
ble_beacond.ble_adv_interval = interval;
res = RF_BLE_BEACOND_OK;
}
if(name == NULL) {
return RF_BLE_BEACOND_ERROR;
if(name != NULL) {
const size_t name_len = strlen(name);
if((name_len == 0) || (name_len >= BLE_ADV_NAME_BUF_LEN)) {
ble_beacond.adv_name_len = name_len;
memcpy(ble_beacond.adv_name, name, name_len);
res = RF_BLE_BEACOND_OK;
}
}
ble_beacond.ble_adv_interval = interval;
const size_t name_len = strlen(name);
if((name_len == 0) ||
(name_len >= BLE_ADV_NAME_BUF_LEN)) {
return RF_BLE_BEACOND_ERROR;
return res;
}
/*---------------------------------------------------------------------------*/
rf_ble_beacond_result_t
rf_ble_beacond_start(void)
{
if(ble_beacond.is_active) {
return RF_BLE_BEACOND_OK;
}
ble_beacond.adv_name_len = name_len;
memcpy(ble_beacond.adv_name, name, name_len);
ble_beacond.is_active = true;
process_start(&ble_beacond_process, NULL);
@ -175,6 +187,10 @@ rf_ble_beacond_start(clock_time_t interval, const char *name)
rf_ble_beacond_result_t
rf_ble_beacond_stop(void)
{
if(!ble_beacond.is_active) {
return RF_BLE_BEACOND_OK;
}
ble_beacond.is_active = false;
process_exit(&ble_beacond_process);
@ -197,7 +213,7 @@ rf_ble_set_tx_power(int8_t dbm)
return RADIO_RESULT_INVALID_VALUE;
}
res = rf_set_tx_power(ble_beacond.rf_handle, TX_POWER_TABLE, dbm);
res = rf_set_tx_power(ble_beacond.rf_handle, ble_tx_power_table, dbm);
return (res == RF_RESULT_OK)
? RF_BLE_BEACOND_OK
@ -210,7 +226,7 @@ rf_ble_get_tx_power(void)
rf_result_t res;
int8_t dbm;
res = rf_get_tx_power(ble_beacond.rf_handle, TX_POWER_TABLE, &dbm);
res = rf_get_tx_power(ble_beacond.rf_handle, ble_tx_power_table, &dbm);
if(res != RF_RESULT_OK) {
return RF_TxPowerTable_INVALID_DBM;
@ -254,8 +270,8 @@ PROCESS_THREAD(ble_beacond_process, ev, data)
PROCESS_BEGIN();
while(1) {
etimer_set(&beacond_config.ble_adv_et, beacond_config.ble_adv_interval);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&beacond_config.ble_adv_et) ||
etimer_set(&ble_beacond.ble_adv_et, ble_beacond.ble_adv_interval);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&ble_beacond.ble_adv_et) ||
(ev == PROCESS_EVENT_EXIT));
if(ev == PROCESS_EVENT_EXIT) {
@ -266,25 +282,25 @@ PROCESS_THREAD(ble_beacond_process, ev, data)
len = 0;
/* Device info */
beacond_config.tx_buf[len++] = (uint8_t)0x02; /* 2 bytes */
beacond_config.tx_buf[len++] = (uint8_t)BLE_ADV_TYPE_DEVINFO;
beacond_config.tx_buf[len++] = (uint8_t)0x1A; /* LE general discoverable + BR/EDR */
beacond_config.tx_buf[len++] = (uint8_t)beacond_config.adv_name_len;
beacond_config.tx_buf[len++] = (uint8_t)BLE_ADV_TYPE_NAME;
ble_beacond.tx_buf[len++] = (uint8_t)0x02; /* 2 bytes */
ble_beacond.tx_buf[len++] = (uint8_t)BLE_ADV_TYPE_DEVINFO;
ble_beacond.tx_buf[len++] = (uint8_t)0x1A; /* LE general discoverable + BR/EDR */
ble_beacond.tx_buf[len++] = (uint8_t)ble_beacond.adv_name_len;
ble_beacond.tx_buf[len++] = (uint8_t)BLE_ADV_TYPE_NAME;
memcpy(beacond_config.tx_buf + len, beacond_config.adv_name, beacond_config.adv_name_len);
len += beacond_config.adv_name_len;
memcpy(ble_beacond.tx_buf + len, ble_beacond.adv_name, ble_beacond.adv_name_len);
len += ble_beacond.adv_name_len;
/*
* Send BLE_ADV_MESSAGES beacon bursts. Each burst on all three
* channels, with a BLE_ADV_DUTY_CYCLE interval between bursts
*/
ble_beacon_burst(BLE_ADV_CHANNEL_ALL, beacond_config.tx_buf, len);
ble_beacon_burst(BLE_ADV_CHANNEL_ALL, ble_beacond.tx_buf, len);
for(i = 1; i < BLE_ADV_MESSAGES; ++i) {
etimer_set(&beacond_config.ble_adv_et, BLE_ADV_DUTY_CYCLE);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&ble_adv_et));
etimer_set(&ble_beacond.ble_adv_et, BLE_ADV_DUTY_CYCLE);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&ble_beacond.ble_adv_et));
ble_beacon_burst(BLE_ADV_CHANNEL_ALL, beacond_config.tx_buf, len);
ble_beacon_burst(BLE_ADV_CHANNEL_ALL, ble_beacond.tx_buf, len);
}
}
PROCESS_END();
@ -299,10 +315,19 @@ rf_ble_beacond_init(void)
}
/*---------------------------------------------------------------------------*/
rf_ble_beacond_result_t
rf_ble_beacond_start(clock_time_t interval, const char *name)
rf_ble_beacond_config(clock_time_t interval, const char *name)
{
(void)interval;
(void)name;
return RF_BLE_BEACOND_DISABLED;
}
/*---------------------------------------------------------------------------*/
rf_ble_beacond_result_t
rf_ble_beacond_start(void)
{
return RF_BLE_BEACOND_DISABLED;
}
/*---------------------------------------------------------------------------*/
rf_ble_beacond_result_t
rf_ble_beacond_stop(void)
@ -319,6 +344,7 @@ rf_ble_is_active(void)
rf_ble_beacond_result_t
rf_ble_set_tx_power(int8_t power)
{
(void)power;
return RF_BLE_BEACOND_DISABLED;
}
/*---------------------------------------------------------------------------*/

View File

@ -65,6 +65,17 @@ typedef enum {
*/
rf_ble_beacond_result_t rf_ble_beacond_init(void);
/**
* \brief Set the device name to use with the BLE advertisement/beacon daemon
* \param interval The interval (ticks) between two consecutive beacon bursts
* \param name The device name to advertise
*
* If name is NULL it will be ignored. If interval==0 it will be ignored. Thus,
* this function can be used to configure a single parameter at a time if so
* desired.
*/
rf_ble_beacond_result_t rf_ble_beacond_config(clock_time_t interval, const char *name);
/**
* \brief Start the BLE advertisement/beacon daemon
* \return RF_CORE_CMD_OK: Success, RF_CORE_CMD_ERROR: Failure
@ -73,7 +84,7 @@ rf_ble_beacond_result_t rf_ble_beacond_init(void);
* calling rf_ble_beacond_config(). Otherwise, this function will return an
* error.
*/
rf_ble_beacond_result_t rf_ble_beacond_start(clock_time_t interval, const char *name);
rf_ble_beacond_result_t rf_ble_beacond_start(void);
/**
* \brief Stop the BLE advertisement/beacon daemon

View File

@ -95,9 +95,9 @@
#elif (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X2_CC26X2)
#define ble_mode rf_ble_mode
#define ble_cmd_radio_setup rf_cmd_ble5_radio_setup
#define ble_adv_par rf_ble5_adv_aux_par
#define ble_cmd_beacon rf_cmd_ble5_adv_aux
#define ble_cmd_radio_setup rf_ble_cmd_radio_setup
#define ble_adv_par rf_ble_adv_par
#define ble_cmd_beacon rf_ble_cmd_ble_adv_nc
#endif /* DeviceFamily_PARENT */

View File

@ -323,7 +323,7 @@ ext_flash_open(spi_device_t *conf)
flash_spi_configuration = get_spi_conf(conf);
/* Check if platform has ext-flash */
if(flash_spi_configuration->pin_spi_sck == GPIO_HAL_PIN_UNKNOWN) {
if(flash_spi_configuration->pin_spi_cs == GPIO_HAL_PIN_UNKNOWN) {
return false;
}

View File

@ -69,7 +69,7 @@ value(int type)
{
if(enabled == SENSOR_STATUS_DISABLED) {
PRINTF("Sensor Disabled\n");
return 0;
return BATMON_SENSOR_READING_ERROR;
}
switch(type) {
@ -77,7 +77,7 @@ value(int type)
case BATMON_SENSOR_TYPE_VOLT: return (int)AONBatMonBatteryVoltageGet();
default:
PRINTF("Invalid type\n");
return 0;
return BATMON_SENSOR_READING_ERROR;
}
}
/*---------------------------------------------------------------------------*/

View File

@ -46,6 +46,8 @@
#define BATMON_SENSOR_TYPE_TEMP 1
#define BATMON_SENSOR_TYPE_VOLT 2
/*---------------------------------------------------------------------------*/
#define BATMON_SENSOR_READING_ERROR -1
/*---------------------------------------------------------------------------*/
extern const struct sensors_sensor batmon_sensor;
/*---------------------------------------------------------------------------*/
#endif /* BATMON_SENSOR_H_ */

View File

@ -88,10 +88,24 @@
/**
* \name The external flash SPI CS pin, defined in Board.h.
*
* Note that SPI SCK, MOSI and MISO does not need to be defined, as they are
* implicitly defined via the Board_SPI0 controller.
*
* Those values are not meant to be modified by the user
* @{
*/
#define EXT_FLASH_SPI_PIN_CS Board_SPI_FLASH_CS
#define EXT_FLASH_SPI_CONTROLLER Board_SPI0
#define EXT_FLASH_SPI_PIN_SCK GPIO_HAL_PIN_UNKNOWN
#define EXT_FLASH_SPI_PIN_MOSI GPIO_HAL_PIN_UNKNOWN
#define EXT_FLASH_SPI_PIN_MISO GPIO_HAL_PIN_UNKNOWN
#define EXT_FLASH_SPI_PIN_CS Board_SPI_FLASH_CS
#define EXT_FLASH_DEVICE_ID 0x14
#define EXT_FLASH_MID 0xC2
#define EXT_FLASH_PROGRAM_PAGE_SIZE 256
#define EXT_FLASH_ERASE_SECTOR_SIZE 4096
/** @} */
/*---------------------------------------------------------------------------*/
#endif /* BOARD_CONF_H_ */

View File

@ -89,7 +89,18 @@
* Those values are not meant to be modified by the user
* @{
*/
#define EXT_FLASH_SPI_PIN_CS Board_SPI_FLASH_CS
#define EXT_FLASH_SPI_CONTROLLER Board_SPI0
#define EXT_FLASH_SPI_PIN_SCK GPIO_HAL_PIN_UNKNOWN
#define EXT_FLASH_SPI_PIN_MOSI GPIO_HAL_PIN_UNKNOWN
#define EXT_FLASH_SPI_PIN_MISO GPIO_HAL_PIN_UNKNOWN
#define EXT_FLASH_SPI_PIN_CS Board_SPI_FLASH_CS
#define EXT_FLASH_DEVICE_ID 0x14
#define EXT_FLASH_MID 0xC2
#define EXT_FLASH_PROGRAM_PAGE_SIZE 256
#define EXT_FLASH_ERASE_SECTOR_SIZE 4096
/** @} */
/*---------------------------------------------------------------------------*/
#endif /* BOARD_CONF_H_ */

View File

@ -1,10 +1,8 @@
CONTIKI_PROJECT = start-demo
PROJECT_SOURCEFILES = start-demo.c
PLATFORMS_ONLY = simplelink
all: $(CONTIKI_PROJECT).$(TARGET)
all: $(CONTIKI_PROJECT)
CONTIKI = ../../../../..
include $(CONTIKI)/Makefile.include

View File

@ -1,10 +1,12 @@
CONTIKI_PROJECT = very-sleepy-demo
PLATFORMS_ONLY = srf06-cc26xx
PLATFORMS_ONLY = simplelink
all: $(CONTIKI_PROJECT)
all: $(CONTIKI_PROJECT).$(TARGET)
SMALL = 1
MODULES += os/net/app-layer/coap
CONTIKI = ../../../..
CONTIKI = ../../../../..
include $(CONTIKI)/Makefile.include

View File

@ -31,25 +31,31 @@
#ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
/*---------------------------------------------------------------------------*/
/* Change to match your configuration */
#define IEEE802154_CONF_PANID 0xABCD
#define IEEE802154_CONF_DEFAULT_CHANNEL 25
/* Platform configuration */
#define BOARD_CONF_SENSORS_DISABLE 1
#define WATCHDOG_CONF_DISABLE 1
/*---------------------------------------------------------------------------*/
/* Enable the ROM bootloader */
#define ROM_BOOTLOADER_ENABLE 1
/* Nestack configuration */
#define IEEE802154_CONF_PANID 0xABCD
#define IEEE802154_CONF_DEFAULT_CHANNEL 25
//#define RF_CONF_MODE RF_MODE_SUB_1_GHZ
#define RF_CONF_MODE RF_MODE_2_4_GHZ
#define RF_CONF_BLE_BEACON_ENABLE 0
/*---------------------------------------------------------------------------*/
/* TI drivers configuration */
#define TI_SPI_CONF_ENABLE 0
#define TI_I2C_CONF_ENABLE 0
/*---------------------------------------------------------------------------*/
/* For very sleepy operation */
#define RF_BLE_CONF_ENABLED 0
#define UIP_DS6_CONF_PERIOD CLOCK_SECOND
#define UIP_CONF_TCP 0
#define RPL_CONF_LEAF_ONLY 1
#define UIP_DS6_CONF_PERIOD CLOCK_SECOND
#define UIP_CONF_TCP 0
#define RPL_CONF_LEAF_ONLY 1
/*
* We'll fail without RPL probing, so turn it on explicitly even though it's
* on by default
*/
#define RPL_CONF_WITH_PROBING 1
#define RPL_CONF_WITH_PROBING 1
/*---------------------------------------------------------------------------*/
#endif /* PROJECT_CONF_H_ */
/*---------------------------------------------------------------------------*/

View File

@ -32,20 +32,20 @@
#include "sys/etimer.h"
#include "sys/stimer.h"
#include "sys/process.h"
#include "lib/sensors.h"
#include "dev/leds.h"
#include "dev/watchdog.h"
#include "dev/button-hal.h"
#include "batmon-sensor.h"
#include "board-peripherals.h"
#include "net/netstack.h"
#include "net/ipv6/uip-ds6-nbr.h"
#include "net/ipv6/uip-ds6-route.h"
#include "net/routing/routing.h"
#include "coap-engine.h"
#include "coap.h"
#include "ti-lib.h"
#include "net/app-layer/coap/coap.h"
#include "net/app-layer/coap/coap-engine.h"
/*---------------------------------------------------------------------------*/
#include "board-peripherals.h"
#include "batmon-sensor.h"
/*---------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>

View File

@ -1,9 +1,10 @@
CONTIKI_PROJECT = web-demo
all: $(CONTIKI_PROJECT)
all: $(CONTIKI_PROJECT).$(TARGET)
MODULES_REL += ./resources
PROJECT_SOURCEFILES += web-demo.c coap-server.c net-uart.c mqtt-client.c
PROJECT_SOURCEFILES += coap-server.c net-uart.c mqtt-client.c
PROJECT_SOURCEFILES += httpd-simple.c
ifeq ($(MAKE_ROUTING),MAKE_ROUTING_RPL_CLASSIC)
@ -11,9 +12,12 @@ ifeq ($(MAKE_ROUTING),MAKE_ROUTING_RPL_CLASSIC)
PROJECT_SOURCEFILES += cetic-6lbr-client.c
endif
SMALL = 1
# REST Engine shall use Erbium CoAP implementation
MODULES += os/net/app-layer/mqtt
MODULES += os/net/app-layer/coap
MODULES += arch/dev/ext-flash
CONTIKI=../../../..
CONTIKI = ../../../../..
include $(CONTIKI)/Makefile.include

View File

@ -24,7 +24,7 @@
* SUCH DAMAGE.
*/
/**
* \addtogroup cc26xx-web-demo
* \addtogroup cc13xx-cc26xx-web-demo
* @{
*
* \file
@ -35,21 +35,21 @@
#include "contiki.h"
#include "contiki-lib.h"
#include "contiki-net.h"
#include "net/routing/routing.h"
#include "net/ipv6/uip.h"
#if ROUTING_CONF_RPL_CLASSIC
#include "net/routing/routing.h"
#include "net/routing/rpl-classic/rpl.h"
#include "net/routing/rpl-classic/rpl-private.h"
#else
#error The 6LBR client is only meant for RPL Classic. Set MAKE_ROUTING accordingly.
#endif
/*---------------------------------------------------------------------------*/
#include <string.h>
#include <stdio.h>
/*---------------------------------------------------------------------------*/
#define DEBUG 0
#include "net/ipv6/uip-debug.h"
/*---------------------------------------------------------------------------*/
#if (ROUTING_CONF_RPL_CLASSIC == 0)
#error "The 6LBR client is only meant for RPL Classic. Set MAKE_ROUTING accordingly."
#endif
/*---------------------------------------------------------------------------*/
#ifndef CETIC_6LBR_NODE_INFO_PORT
#define CETIC_6LBR_NODE_INFO_PORT 3000
#endif

View File

@ -28,20 +28,22 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup cc26xx-web-demo
* \addtogroup cc13xx-cc26xx-web-demo
* @{
*
* \file
* A CC26XX-specific CoAP server
* A CC13xx/CC26xx-specific CoAP server
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "contiki-net.h"
#include "coap-engine.h"
#include "net/app-layer/coap/coap-engine.h"
/*---------------------------------------------------------------------------*/
#include "board-peripherals.h"
#include "rf-core/rf-ble.h"
#include "cc26xx-web-demo.h"
#include "rf/ble-beacond.h"
/*---------------------------------------------------------------------------*/
#include "web-demo.h"
/*---------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -60,7 +62,7 @@ extern coap_resource_t res_device_cfg_reset;
extern coap_resource_t res_parent_rssi;
extern coap_resource_t res_parent_ip;
#if RF_BLE_ENABLED
#if RF_CONF_BLE_BEACON_ENABLE
extern coap_resource_t res_ble_advd;
#endif
@ -87,7 +89,7 @@ extern coap_resource_t res_toggle_orange;
extern coap_resource_t res_toggle_yellow;
#endif
#if CC26XX_WEB_DEMO_ADC_DEMO
#if WEB_DEMO_ADC_DEMO
extern coap_resource_t res_adc_dio23;
#endif
/*---------------------------------------------------------------------------*/
@ -125,18 +127,18 @@ start_board_resources(void)
#endif
}
/*---------------------------------------------------------------------------*/
PROCESS(coap_server_process, "CC26XX CoAP Server");
PROCESS(coap_server_process, "CC13xx/CC26xx CoAP Server");
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(coap_server_process, ev, data)
{
PROCESS_BEGIN();
printf("CC26XX CoAP Server\n");
printf("CC13xx/CC26xx CoAP Server\n");
coap_activate_resource(&res_batmon_temp, "sen/batmon/temp");
coap_activate_resource(&res_batmon_volt, "sen/batmon/voltage");
#if CC26XX_WEB_DEMO_ADC_DEMO
#if WEB_DEMO_ADC_DEMO
coap_activate_resource(&res_adc_dio23, "sen/adc/dio23");
#endif
@ -148,7 +150,7 @@ PROCESS_THREAD(coap_server_process, ev, data)
coap_activate_resource(&res_parent_rssi, "net/parent/RSSI");
coap_activate_resource(&res_parent_ip, "net/parent/IPv6");
#if RF_BLE_ENABLED
#if RF_CONF_BLE_BEACON_ENABLE
coap_activate_resource(&res_ble_advd, "dev/ble_advd");
#endif

View File

@ -28,11 +28,11 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup cc26xx-web-demo
* \addtogroup cc13xx-cc26xx-web-demo
* @{
*
* \file
* Header file for the CC26xx web demo CoAP functionality
* Header file for the CC13xx/CC26xx web demo CoAP functionality
*/
/*---------------------------------------------------------------------------*/
#include "sys/process.h"

View File

@ -29,7 +29,7 @@
*
*/
/**
* \addtogroup cc26xx-web-demo
* \addtogroup cc13xx-cc26xx-web-demo
* @{
*
* \file
@ -37,15 +37,17 @@
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "httpd-simple.h"
#include "net/ipv6/uip-ds6-route.h"
#include "batmon-sensor.h"
#include "lib/sensors.h"
#include "lib/list.h"
#include "cc26xx-web-demo.h"
/*---------------------------------------------------------------------------*/
#include "batmon-sensor.h"
/*---------------------------------------------------------------------------*/
#include "web-demo.h"
#include "mqtt-client.h"
#include "httpd-simple.h"
#include "net-uart.h"
/*---------------------------------------------------------------------------*/
#include <stdint.h>
#include <string.h>
#include <strings.h>
@ -93,8 +95,8 @@ static int state;
#define STRINGIFY(x) XSTR(x)
#define XSTR(x) #x
#define RSSI_INT_MAX STRINGIFY(CC26XX_WEB_DEMO_RSSI_MEASURE_INTERVAL_MAX)
#define RSSI_INT_MIN STRINGIFY(CC26XX_WEB_DEMO_RSSI_MEASURE_INTERVAL_MIN)
#define RSSI_INT_MAX STRINGIFY(WEB_DEMO_RSSI_MEASURE_INTERVAL_MAX)
#define RSSI_INT_MIN STRINGIFY(WEB_DEMO_RSSI_MEASURE_INTERVAL_MIN)
#define PUB_INT_MAX STRINGIFY(MQTT_CLIENT_PUBLISH_INTERVAL_MAX)
#define PUB_INT_MIN STRINGIFY(MQTT_CLIENT_PUBLISH_INTERVAL_MIN)
/*---------------------------------------------------------------------------*/
@ -109,7 +111,7 @@ static int state;
*/
static struct httpd_state *lock;
/*---------------------------------------------------------------------------*/
PROCESS(httpd_simple_process, "CC26XX Web Server");
PROCESS(httpd_simple_process, "CC13xx/CC26xx Web Server");
/*---------------------------------------------------------------------------*/
#define ISO_nl 0x0A
#define ISO_space 0x20
@ -216,7 +218,7 @@ static page_t http_dev_cfg_page = {
generate_config,
};
#if CC26XX_WEB_DEMO_NET_UART
#if WEB_DEMO_NET_UART
static char generate_net_uart_config(struct httpd_state *s);
static page_t http_net_cfg_page = {
@ -227,7 +229,7 @@ static page_t http_net_cfg_page = {
};
#endif
#if CC26XX_WEB_DEMO_MQTT_CLIENT
#if WEB_DEMO_MQTT_CLIENT
static char generate_mqtt_config(struct httpd_state *s);
static page_t http_mqtt_cfg_page = {
@ -257,7 +259,7 @@ struct httpd_state {
struct psock sin, sout;
int blen;
const char **ptr;
const cc26xx_web_demo_sensor_reading_t *reading;
const web_demo_sensor_reading_t *reading;
const page_t *page;
uip_ds6_route_t *r;
uip_ds6_nbr_t *nbr;
@ -411,7 +413,7 @@ PT_THREAD(generate_top_matter(struct httpd_state *s, const char *title,
s->page->filename, s->page->title));
}
#if CC26XX_WEB_DEMO_MQTT_CLIENT
#if WEB_DEMO_MQTT_CLIENT
PT_WAIT_THREAD(&s->top_matter_pt,
enqueue_chunk(s, 0, " | %s", http_mqtt_a));
#endif
@ -442,7 +444,7 @@ PT_THREAD(generate_index(struct httpd_state *s))
PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "\n"));
memset(ipaddr_buf, 0, IPADDR_BUF_LEN);
cc26xx_web_demo_ipaddr_sprintf(ipaddr_buf, IPADDR_BUF_LEN, &s->nbr->ipaddr);
web_demo_ipaddr_sprintf(ipaddr_buf, IPADDR_BUF_LEN, &s->nbr->ipaddr);
PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "%s", ipaddr_buf));
memset(ipaddr_buf, 0, IPADDR_BUF_LEN);
@ -459,7 +461,7 @@ PT_THREAD(generate_index(struct httpd_state *s))
SECTION_OPEN "Default Route" CONTENT_OPEN));
memset(ipaddr_buf, 0, IPADDR_BUF_LEN);
cc26xx_web_demo_ipaddr_sprintf(ipaddr_buf, IPADDR_BUF_LEN,
web_demo_ipaddr_sprintf(ipaddr_buf, IPADDR_BUF_LEN,
uip_ds6_defrt_choose());
PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "%s", ipaddr_buf));
@ -475,14 +477,14 @@ PT_THREAD(generate_index(struct httpd_state *s))
PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "\n"));
memset(ipaddr_buf, 0, IPADDR_BUF_LEN);
cc26xx_web_demo_ipaddr_sprintf(ipaddr_buf, IPADDR_BUF_LEN, &s->r->ipaddr);
web_demo_ipaddr_sprintf(ipaddr_buf, IPADDR_BUF_LEN, &s->r->ipaddr);
PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "%s", ipaddr_buf));
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, " / %u via ", s->r->length));
memset(ipaddr_buf, 0, IPADDR_BUF_LEN);
cc26xx_web_demo_ipaddr_sprintf(ipaddr_buf, IPADDR_BUF_LEN,
web_demo_ipaddr_sprintf(ipaddr_buf, IPADDR_BUF_LEN,
uip_ds6_route_nexthop(s->r));
PT_WAIT_THREAD(&s->generate_pt, enqueue_chunk(s, 0, "%s", ipaddr_buf));
@ -498,7 +500,7 @@ PT_THREAD(generate_index(struct httpd_state *s))
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, SECTION_OPEN "Sensors" CONTENT_OPEN));
for(s->reading = cc26xx_web_demo_sensor_first();
for(s->reading = web_demo_sensor_first();
s->reading != NULL; s->reading = s->reading->next) {
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "\n%s = %s %s", s->reading->descr,
@ -547,7 +549,7 @@ PT_THREAD(generate_config(struct httpd_state *s))
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "accept-charset=\"UTF-8\">"));
for(s->reading = cc26xx_web_demo_sensor_first();
for(s->reading = web_demo_sensor_first();
s->reading != NULL; s->reading = s->reading->next) {
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "%s%s:%s%s", config_div_left,
@ -576,7 +578,7 @@ PT_THREAD(generate_config(struct httpd_state *s))
enqueue_chunk(s, 0, "</form>"));
/* RSSI measurements */
#if CC26XX_WEB_DEMO_READ_PARENT_RSSI
#if WEB_DEMO_READ_PARENT_RSSI
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "<h1>RSSI Probing</h1>"));
@ -600,7 +602,7 @@ PT_THREAD(generate_config(struct httpd_state *s))
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "value=\"%lu\" ",
(clock_time_t)
(cc26xx_web_demo_config.def_rt_ping_interval
(web_demo_config.def_rt_ping_interval
/ CLOCK_SECOND)));
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0,
@ -641,7 +643,7 @@ PT_THREAD(generate_config(struct httpd_state *s))
PT_END(&s->generate_pt);
}
/*---------------------------------------------------------------------------*/
#if CC26XX_WEB_DEMO_MQTT_CLIENT
#if WEB_DEMO_MQTT_CLIENT
static
PT_THREAD(generate_mqtt_config(struct httpd_state *s))
{
@ -675,7 +677,7 @@ PT_THREAD(generate_mqtt_config(struct httpd_state *s))
config_div_right));
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "value=\"%s\" ",
cc26xx_web_demo_config.mqtt_config.type_id));
web_demo_config.mqtt_config.type_id));
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "name=\"type_id\">%s", config_div_close));
@ -687,7 +689,7 @@ PT_THREAD(generate_mqtt_config(struct httpd_state *s))
config_div_right));
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "value=\"%s\" ",
cc26xx_web_demo_config.mqtt_config.org_id));
web_demo_config.mqtt_config.org_id));
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "name=\"org_id\">%s", config_div_close));
@ -711,7 +713,7 @@ PT_THREAD(generate_mqtt_config(struct httpd_state *s))
config_div_right));
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "value=\"%s\" ",
cc26xx_web_demo_config.mqtt_config.cmd_type));
web_demo_config.mqtt_config.cmd_type));
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "name=\"cmd_type\">%s",
config_div_close));
@ -724,7 +726,7 @@ PT_THREAD(generate_mqtt_config(struct httpd_state *s))
config_div_right));
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "value=\"%s\" ",
cc26xx_web_demo_config.mqtt_config.event_type_id));
web_demo_config.mqtt_config.event_type_id));
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "name=\"event_type_id\">%s",
config_div_close));
@ -738,7 +740,7 @@ PT_THREAD(generate_mqtt_config(struct httpd_state *s))
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "value=\"%lu\" ",
(clock_time_t)
(cc26xx_web_demo_config.mqtt_config.pub_interval
(web_demo_config.mqtt_config.pub_interval
/ CLOCK_SECOND)));
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0,
@ -755,7 +757,7 @@ PT_THREAD(generate_mqtt_config(struct httpd_state *s))
config_div_right));
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "value=\"%s\" ",
cc26xx_web_demo_config.mqtt_config.broker_ip));
web_demo_config.mqtt_config.broker_ip));
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "name=\"broker_ip\">%s",
config_div_close));
@ -768,7 +770,7 @@ PT_THREAD(generate_mqtt_config(struct httpd_state *s))
config_div_right));
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "value=\"%d\" ",
cc26xx_web_demo_config.mqtt_config.broker_port));
web_demo_config.mqtt_config.broker_port));
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "min=\"1\" max=\"65535\" "
"name=\"broker_port\">%s",
@ -803,7 +805,7 @@ PT_THREAD(generate_mqtt_config(struct httpd_state *s))
}
#endif
/*---------------------------------------------------------------------------*/
#if CC26XX_WEB_DEMO_NET_UART
#if WEB_DEMO_NET_UART
static
PT_THREAD(generate_net_uart_config(struct httpd_state *s))
{
@ -838,7 +840,7 @@ PT_THREAD(generate_net_uart_config(struct httpd_state *s))
config_div_right));
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "value=\"%s\" ",
cc26xx_web_demo_config.net_uart.remote_address));
web_demo_config.net_uart.remote_address));
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "name=\"net_uart_ip\">%s",
config_div_close));
@ -851,7 +853,7 @@ PT_THREAD(generate_net_uart_config(struct httpd_state *s))
config_div_right));
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "value=\"%u\" ",
cc26xx_web_demo_config.net_uart.remote_port));
web_demo_config.net_uart.remote_port));
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "min=\"1\" max=\"65535\" "
"name=\"net_uart_port\">%s",
@ -866,14 +868,14 @@ PT_THREAD(generate_net_uart_config(struct httpd_state *s))
enqueue_chunk(s, 0, "<input type=\"radio\" value=\"1\" "));
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "title=\"On\" name=\"net_uart_on\"%s>",
cc26xx_web_demo_config.net_uart.enable ?
web_demo_config.net_uart.enable ?
" Checked" : ""));
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "<input type=\"radio\" value=\"0\" "));
PT_WAIT_THREAD(&s->generate_pt,
enqueue_chunk(s, 0, "title=\"Off\" name=\"net_uart_on\""
"%s>%s",
cc26xx_web_demo_config.net_uart.enable ?
web_demo_config.net_uart.enable ?
"" : " Checked", config_div_close));
PT_WAIT_THREAD(&s->generate_pt,
@ -1310,11 +1312,11 @@ init(void)
list_add(pages_list, &http_index_page);
list_add(pages_list, &http_dev_cfg_page);
#if CC26XX_WEB_DEMO_NET_UART
#if WEB_DEMO_NET_UART
list_add(pages_list, &http_net_cfg_page);
#endif
#if CC26XX_WEB_DEMO_MQTT_CLIENT
#if WEB_DEMO_MQTT_CLIENT
list_add(pages_list, &http_mqtt_cfg_page);
#endif
}

View File

@ -31,7 +31,7 @@
/*---------------------------------------------------------------------------*/
/**
* \file
* Header file for the HTTPD of the cc26xx web demo example.
* Header file for the HTTPD of the CC13xx/CC26xx web demo example.
* \author
* Adam Dunkels <adam@sics.se>
* Niclas Finne <nfi@sics.se>
@ -44,7 +44,8 @@
/*---------------------------------------------------------------------------*/
#include "contiki-net.h"
#include "sys/process.h"
#include "cc26xx-web-demo.h"
/*---------------------------------------------------------------------------*/
#include "web-demo.h"
/*---------------------------------------------------------------------------*/
/* Ideally a multiple of TCP_MSS */
#ifdef HTTPD_SIMPLE_CONF_MAIN_BUF_SIZE

View File

@ -28,28 +28,30 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup cc26xx-web-demo
* \addtogroup cc13xx-cc26xx-web-demo
* @{
*
* \file
* MQTT/IBM cloud service client for the CC26XX web demo.
* MQTT/IBM cloud service client for the CC13xx/CC26xx web demo.
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "net/routing/routing.h"
#include "mqtt.h"
#include "net/ipv6/uip.h"
#include "net/ipv6/uip-icmp6.h"
#include "dev/button-hal.h"
#include "dev/leds.h"
#include "sys/etimer.h"
#include "sys/ctimer.h"
#include "net/routing/routing.h"
#include "net/ipv6/uip.h"
#include "net/ipv6/uip-icmp6.h"
#include "net/app-layer/mqtt/mqtt.h"
#include "lib/sensors.h"
#include "dev/button-hal.h"
/*---------------------------------------------------------------------------*/
#include "board-peripherals.h"
#include "cc26xx-web-demo.h"
#include "dev/leds.h"
#include "mqtt-client.h"
/*---------------------------------------------------------------------------*/
#include "web-demo.h"
#include "httpd-simple.h"
#include "mqtt-client.h"
/*---------------------------------------------------------------------------*/
#include <string.h>
#include <strings.h>
/*---------------------------------------------------------------------------*/
@ -139,16 +141,16 @@ static uip_ip6addr_t def_route;
/* Parent RSSI functionality */
extern int def_rt_rssi;
/*---------------------------------------------------------------------------*/
const static cc26xx_web_demo_sensor_reading_t *reading;
const static web_demo_sensor_reading_t *reading;
/*---------------------------------------------------------------------------*/
mqtt_client_config_t *conf;
/*---------------------------------------------------------------------------*/
PROCESS(mqtt_client_process, "CC26XX MQTT Client");
PROCESS(mqtt_client_process, "CC13xx/CC26xx MQTT Client");
/*---------------------------------------------------------------------------*/
static void
publish_led_off(void *d)
{
leds_off(CC26XX_WEB_DEMO_STATUS_LED);
leds_off(WEB_DEMO_STATUS_LED);
}
/*---------------------------------------------------------------------------*/
static void
@ -579,14 +581,14 @@ init_config()
/* Populate configuration with default values */
memset(conf, 0, sizeof(mqtt_client_config_t));
memcpy(conf->org_id, CC26XX_WEB_DEMO_DEFAULT_ORG_ID, 11);
memcpy(conf->type_id, CC26XX_WEB_DEMO_DEFAULT_TYPE_ID, 7);
memcpy(conf->event_type_id, CC26XX_WEB_DEMO_DEFAULT_EVENT_TYPE_ID, 7);
memcpy(conf->org_id, WEB_DEMO_DEFAULT_ORG_ID, 11);
memcpy(conf->type_id, WEB_DEMO_DEFAULT_TYPE_ID, 7);
memcpy(conf->event_type_id, WEB_DEMO_DEFAULT_EVENT_TYPE_ID, 7);
memcpy(conf->broker_ip, broker_ip, strlen(broker_ip));
memcpy(conf->cmd_type, CC26XX_WEB_DEMO_DEFAULT_SUBSCRIBE_CMD_TYPE, 1);
memcpy(conf->cmd_type, WEB_DEMO_DEFAULT_SUBSCRIBE_CMD_TYPE, 1);
conf->broker_port = CC26XX_WEB_DEMO_DEFAULT_BROKER_PORT;
conf->pub_interval = CC26XX_WEB_DEMO_DEFAULT_PUBLISH_INTERVAL;
conf->broker_port = WEB_DEMO_DEFAULT_BROKER_PORT;
conf->pub_interval = WEB_DEMO_DEFAULT_PUBLISH_INTERVAL;
return 1;
}
@ -649,7 +651,7 @@ publish(void)
/* Put our Default route's string representation in a buffer */
memset(def_rt_str, 0, sizeof(def_rt_str));
cc26xx_web_demo_ipaddr_sprintf(def_rt_str, sizeof(def_rt_str),
web_demo_ipaddr_sprintf(def_rt_str, sizeof(def_rt_str),
uip_ds6_defrt_choose());
len = snprintf(buf_ptr, remaining, ",\"Def Route\":\"%s\",\"RSSI (dBm)\":%d",
@ -664,9 +666,9 @@ publish(void)
memcpy(&def_route, uip_ds6_defrt_choose(), sizeof(uip_ip6addr_t));
for(reading = cc26xx_web_demo_sensor_first();
for(reading = web_demo_sensor_first();
reading != NULL; reading = reading->next) {
if(reading->publish && reading->raw != CC26XX_SENSOR_READING_ERROR) {
if(reading->publish && reading->raw != -1) {
len = snprintf(buf_ptr, remaining,
",\"%s (%s)\":%s", reading->descr, reading->units,
reading->converted);
@ -751,11 +753,11 @@ state_machine(void)
DBG("Registered. Connect attempt %u\n", connect_attempt);
connect_to_broker();
}
etimer_set(&publish_periodic_timer, CC26XX_WEB_DEMO_NET_CONNECT_PERIODIC);
etimer_set(&publish_periodic_timer, WEB_DEMO_NET_CONNECT_PERIODIC);
return;
break;
case MQTT_CLIENT_STATE_CONNECTING:
leds_on(CC26XX_WEB_DEMO_STATUS_LED);
leds_on(WEB_DEMO_STATUS_LED);
ctimer_set(&ct, CONNECTING_LED_DURATION, publish_led_off, NULL);
/* Not connected yet. Wait */
DBG("Connecting (%u)\n", connect_attempt);
@ -783,7 +785,7 @@ state_machine(void)
subscribe();
state = MQTT_CLIENT_STATE_PUBLISHING;
} else {
leds_on(CC26XX_WEB_DEMO_STATUS_LED);
leds_on(WEB_DEMO_STATUS_LED);
ctimer_set(&ct, PUBLISH_LED_ON_DURATION, publish_led_off, NULL);
publish();
}
@ -846,7 +848,7 @@ state_machine(void)
return;
case MQTT_CLIENT_STATE_ERROR:
default:
leds_on(CC26XX_WEB_DEMO_STATUS_LED);
leds_on(WEB_DEMO_STATUS_LED);
/*
* 'default' should never happen.
*
@ -866,9 +868,9 @@ PROCESS_THREAD(mqtt_client_process, ev, data)
PROCESS_BEGIN();
printf("CC26XX MQTT Client Process\n");
printf("CC13xx/CC26xx MQTT Client Process\n");
conf = &cc26xx_web_demo_config.mqtt_config;
conf = &web_demo_config.mqtt_config;
if(init_config() != 1) {
PROCESS_EXIT();
}
@ -885,7 +887,7 @@ PROCESS_THREAD(mqtt_client_process, ev, data)
if(ev == button_hal_release_event) {
button_hal_button_t *btn = (button_hal_button_t *)data;
if(btn->unique_id == CC26XX_WEB_DEMO_MQTT_PUBLISH_TRIGGER) {
if(btn->unique_id == WEB_DEMO_MQTT_PUBLISH_TRIGGER) {
if(state == MQTT_CLIENT_STATE_ERROR) {
connect_attempt = 1;
state = MQTT_CLIENT_STATE_REGISTERED;
@ -904,14 +906,14 @@ PROCESS_THREAD(mqtt_client_process, ev, data)
if((ev == PROCESS_EVENT_TIMER && data == &publish_periodic_timer) ||
ev == PROCESS_EVENT_POLL ||
ev == cc26xx_web_demo_publish_event ||
ev == web_demo_publish_event ||
(ev == button_hal_release_event &&
((button_hal_button_t *)data)->unique_id ==
CC26XX_WEB_DEMO_MQTT_PUBLISH_TRIGGER)) {
WEB_DEMO_MQTT_PUBLISH_TRIGGER)) {
state_machine();
}
if(ev == cc26xx_web_demo_load_config_defaults) {
if(ev == web_demo_load_config_defaults) {
init_config();
etimer_set(&publish_periodic_timer, NEW_CONFIG_WAIT_INTERVAL);
}

View File

@ -28,11 +28,11 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup cc26xx-web-demo
* \addtogroup cc13xx-cc26xx-web-demo
* @{
*
* \file
* Header file for the CC26xx web demo MQTT client functionality
* Header file for the CC13xx/CC26xx web demo MQTT client functionality
*/
/*---------------------------------------------------------------------------*/
#ifndef MQTT_CLIENT_H_

View File

@ -28,7 +28,7 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup cc26xx-web-demo
* \addtogroup cc13xx-cc26xx-web-demo
* @{
*
* \file
@ -44,7 +44,7 @@
*
* (REMOTE_PORT should be the actual value of the define below, e.g. 7777)
*
* Once netcat is up and listening, type something to the CC26xx's terminal
* Once netcat is up and listening, type something to the CC13xx/CC26xx's terminal
* Bear in mind that the datagram will only be sent after a 0x0a (LF) char
* has been received. Therefore, if you are on Win, do NOT use PuTTY for
* this purpose, since it does not send 0x0a as part of the line end. On
@ -57,18 +57,18 @@
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "sys/cc.h"
#include "sys/process.h"
#include "dev/serial-line.h"
#include "dev/cc26xx-uart.h"
#include "net/ipv6/uip.h"
#include "net/ipv6/uip-udp-packet.h"
#include "net/ipv6/uiplib.h"
/*---------------------------------------------------------------------------*/
#include "uart0-arch.h"
/*---------------------------------------------------------------------------*/
#include "net-uart.h"
#include "httpd-simple.h"
#include "sys/cc.h"
#include "ti-lib.h"
/*---------------------------------------------------------------------------*/
#include <stdint.h>
#include <string.h>
#include <strings.h>
@ -149,13 +149,13 @@ net_input(void)
static void
release_uart(void)
{
cc26xx_uart_set_input(NULL);
uart0_set_callback(NULL);
}
/*---------------------------------------------------------------------------*/
static void
keep_uart_on(void)
{
cc26xx_uart_set_input(serial_line_input_byte);
uart0_set_callback(serial_line_input_byte);
}
/*---------------------------------------------------------------------------*/
static int
@ -172,7 +172,7 @@ remote_port_post_handler(char *key, int key_len, char *val, int val_len)
rv = atoi(val);
if(rv <= 65535 && rv > 0) {
cc26xx_web_demo_config.net_uart.remote_port = (uint16_t)rv;
web_demo_config.net_uart.remote_port = (uint16_t)rv;
} else {
return HTTPD_SIMPLE_POST_HANDLER_ERROR;
}
@ -196,9 +196,9 @@ remote_ipv6_post_handler(char *key, int key_len, char *val, int val_len)
rv = HTTPD_SIMPLE_POST_HANDLER_ERROR;
} else {
if(set_new_ip_address(val)) {
memset(cc26xx_web_demo_config.net_uart.remote_address, 0,
memset(web_demo_config.net_uart.remote_address, 0,
NET_UART_IP_ADDR_STRLEN);
memcpy(cc26xx_web_demo_config.net_uart.remote_address, val, val_len);
memcpy(web_demo_config.net_uart.remote_address, val, val_len);
rv = HTTPD_SIMPLE_POST_HANDLER_OK;
}
}
@ -221,10 +221,10 @@ on_off_post_handler(char *key, int key_len, char *val, int val_len)
/* Be pedantic: only accept 0 and 1, not just any non-zero value */
if(rv == 0) {
cc26xx_web_demo_config.net_uart.enable = 0;
web_demo_config.net_uart.enable = 0;
release_uart();
} else if(rv == 1) {
cc26xx_web_demo_config.net_uart.enable = 1;
web_demo_config.net_uart.enable = 1;
keep_uart_on();
} else {
return HTTPD_SIMPLE_POST_HANDLER_ERROR;
@ -244,17 +244,17 @@ set_config_defaults(void)
set_dest_addr();
/* Set config defaults */
cc26xx_web_demo_ipaddr_sprintf(cc26xx_web_demo_config.net_uart.remote_address,
web_demo_ipaddr_sprintf(web_demo_config.net_uart.remote_address,
NET_UART_IP_ADDR_STRLEN, &remote_addr);
cc26xx_web_demo_config.net_uart.remote_port = REMOTE_PORT;
cc26xx_web_demo_config.net_uart.enable = 1;
web_demo_config.net_uart.remote_port = REMOTE_PORT;
web_demo_config.net_uart.enable = 1;
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(net_uart_process, ev, data)
{
PROCESS_BEGIN();
printf("CC26XX Net UART Process\n");
printf("CC13xx/CC26xx Net UART Process\n");
set_config_defaults();
@ -293,21 +293,21 @@ PROCESS_THREAD(net_uart_process, ev, data)
uip_udp_packet_sendto(
udp_conn, buffer, msg_len, &remote_addr,
UIP_HTONS(cc26xx_web_demo_config.net_uart.remote_port));
UIP_HTONS(web_demo_config.net_uart.remote_port));
}
} else if(ev == tcpip_event) {
net_input();
} else if(ev == cc26xx_web_demo_config_loaded_event) {
} else if(ev == web_demo_config_loaded_event) {
/*
* New config. Check if it's possible to update the remote address.
* The port will have been updated already
*/
set_new_ip_address(cc26xx_web_demo_config.net_uart.remote_address);
set_new_ip_address(web_demo_config.net_uart.remote_address);
if(cc26xx_web_demo_config.net_uart.enable == 1) {
if(web_demo_config.net_uart.enable == 1) {
keep_uart_on();
}
} else if(ev == cc26xx_web_demo_load_config_defaults) {
} else if(ev == web_demo_load_config_defaults) {
set_config_defaults();
}
}

View File

@ -31,7 +31,7 @@
#define NET_UART_H_
/*---------------------------------------------------------------------------*/
#include "net/ipv6/uip.h"
/*---------------------------------------------------------------------------*/
#include <stdint.h>
/*---------------------------------------------------------------------------*/
#define NET_UART_IP_ADDR_STRLEN 64

View File

@ -31,27 +31,36 @@
#ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
/*---------------------------------------------------------------------------*/
/* Platform configuration */
#define BOARD_CONF_SENSORS_DISABLE 1
#define WATCHDOG_CONF_DISABLE 1
/*---------------------------------------------------------------------------*/
/* Change to match your configuration */
#define IEEE802154_CONF_PANID 0xABCD
#define IEEE802154_CONF_DEFAULT_CHANNEL 26
#define RF_BLE_CONF_ENABLED 1
#define IEEE802154_CONF_PANID 0xABCD
#define IEEE802154_CONF_DEFAULT_CHANNEL 25
#define RF_CONF_MODE RF_MODE_2_4_GHZ
#define RF_CONF_BLE_BEACON_ENABLE 1
/*---------------------------------------------------------------------------*/
/* TI drivers configuration */
#define TI_SPI_CONF_ENABLE 1
#define TI_I2C_CONF_ENABLE 0
/*---------------------------------------------------------------------------*/
/* Enable TCP */
#define UIP_CONF_TCP 1
/* Enable/Disable Components of this Demo */
#define CC26XX_WEB_DEMO_CONF_MQTT_CLIENT 1
#define CC26XX_WEB_DEMO_CONF_6LBR_CLIENT ROUTING_CONF_RPL_CLASSIC
#define CC26XX_WEB_DEMO_CONF_COAP_SERVER 1
#define CC26XX_WEB_DEMO_CONF_NET_UART 1
#define WEB_DEMO_CONF_MQTT_CLIENT 1
#define WEB_DEMO_CONF_6LBR_CLIENT ROUTING_CONF_RPL_CLASSIC
#define WEB_DEMO_CONF_COAP_SERVER 1
#define WEB_DEMO_CONF_NET_UART 1
/*
* ADC sensor functionality. To test this, an external voltage source should be
* connected to DIO23
* Enable/Disable DIO23 ADC reading by setting CC26XX_WEB_DEMO_CONF_ADC_DEMO
* Enable/Disable DIO23 ADC reading by setting WEB_DEMO_CONF_ADC_DEMO
*/
#define CC26XX_WEB_DEMO_CONF_ADC_DEMO 0
#define WEB_DEMO_CONF_ADC_DEMO 0
/*---------------------------------------------------------------------------*/
/*
* Change to 1 if you are using an older CC2650 Sensortag (look for Rev: 1.2

View File

@ -28,7 +28,7 @@
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup cc26xx-web-demo
* \addtogroup cc13xx-cc26xx-web-demo
* @{
*
* \file
@ -36,10 +36,11 @@
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "coap-engine.h"
#include "coap.h"
#include "rf-core/rf-ble.h"
#include "net/app-layer/coap/coap.h"
#include "net/app-layer/coap/coap-engine.h"
/*---------------------------------------------------------------------------*/
#include "rf/ble-beacond.h"
/*---------------------------------------------------------------------------*/
#include <string.h>
#include <stdlib.h>
/*---------------------------------------------------------------------------*/

View File

@ -29,49 +29,44 @@
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup cc26xx-web-demo
* \addtogroup cc13xx-cc26xx-web-demo
* @{
*
* \file
* CoAP resource handler for CC26XX software and hardware version
* CoAP resource handler for CC13xx/CC26xx software and hardware version
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "coap-engine.h"
#include "coap.h"
#include "sys/clock.h"
#include "net/app-layer/coap/coap.h"
#include "net/app-layer/coap/coap-engine.h"
/*---------------------------------------------------------------------------*/
#include <ti/devices/DeviceFamily.h>
#include DeviceFamily_constructPath(driverlib/chipinfo.h)
/*---------------------------------------------------------------------------*/
#include "web-demo.h"
#include "coap-server.h"
#include "cc26xx-web-demo.h"
#include "ti-lib.h"
/*---------------------------------------------------------------------------*/
#include <string.h>
#include <stdio.h>
/*---------------------------------------------------------------------------*/
static uint16_t
static const char *
detect_chip(void)
{
if(ti_lib_chipinfo_chip_family_is_cc26xx()) {
if(ti_lib_chipinfo_supports_ieee_802_15_4() == true) {
if(ti_lib_chipinfo_supports_ble() == true) {
return 2650;
} else {
return 2630;
}
} else {
return 2640;
}
} else if(ti_lib_chipinfo_chip_family_is_cc13xx()) {
if(ti_lib_chipinfo_supports_ble() == false &&
ti_lib_chipinfo_supports_ieee_802_15_4() == false) {
return 1310;
} else if(ti_lib_chipinfo_supports_ble() == true &&
ti_lib_chipinfo_supports_ieee_802_15_4() == true) {
return 1350;
}
switch(ChipInfo_GetChipType()) {
case CHIP_TYPE_CC1310: return "CC1310";
case CHIP_TYPE_CC1350: return "CC1350";
case CHIP_TYPE_CC2620: return "CC2620";
case CHIP_TYPE_CC2630: return "CC2630";
case CHIP_TYPE_CC2640: return "CC2640";
case CHIP_TYPE_CC2650: return "CC2650";
case CHIP_TYPE_CC2642: return "CC2642";
case CHIP_TYPE_CC2652: return "CC2652";
case CHIP_TYPE_CC1312: return "CC1312";
case CHIP_TYPE_CC1352: return "CC1352";
case CHIP_TYPE_CC1352P: return "CC1352P";
default: return "Unknown";
}
return 0;
}
/*---------------------------------------------------------------------------*/
static void
@ -80,26 +75,26 @@ res_get_handler_hw(coap_message_t *request, coap_message_t *response,
uint16_t preferred_size, int32_t *offset)
{
unsigned int accept = -1;
uint16_t chip = detect_chip();
const char *chip = detect_chip();
coap_get_header_accept(request, &accept);
if(accept == -1 || accept == TEXT_PLAIN) {
coap_set_header_content_format(response, TEXT_PLAIN);
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%s on CC%u", BOARD_STRING,
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%s on %s", BOARD_STRING,
chip);
coap_set_payload(response, (uint8_t *)buffer, strlen((char *)buffer));
} else if(accept == APPLICATION_JSON) {
coap_set_header_content_format(response, APPLICATION_JSON);
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{\"HW Ver\":\"%s on CC%u\"}",
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{\"HW Ver\":\"%s on %s\"}",
BOARD_STRING, chip);
coap_set_payload(response, buffer, strlen((char *)buffer));
} else if(accept == APPLICATION_XML) {
coap_set_header_content_format(response, APPLICATION_XML);
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE,
"<hw-ver val=\"%s on CC%u\"/>", BOARD_STRING,
"<hw-ver val=\"%s on %s\"/>", BOARD_STRING,
chip);
coap_set_payload(response, buffer, strlen((char *)buffer));
@ -181,7 +176,7 @@ res_post_handler_cfg_reset(coap_message_t *request, coap_message_t *response,
uint8_t *buffer,
uint16_t preferred_size, int32_t *offset)
{
cc26xx_web_demo_restore_defaults();
web_demo_restore_defaults();
}
/*---------------------------------------------------------------------------*/
RESOURCE(res_device_sw,

View File

@ -29,20 +29,20 @@
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup cc26xx-web-demo
* \addtogroup cc13xx-cc26xx-web-demo
* @{
*
* \file
* CoAP resource handler for the CC26xx LEDs. Slightly modified copy of
* CoAP resource handler for the CC13xx/CC26xx LEDs. Slightly modified copy of
* the one found in Contiki's original CoAP example.
* \author
* Matthias Kovatsch <kovatsch@inf.ethz.ch> (original)
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "coap-engine.h"
#include "dev/leds.h"
#include "net/app-layer/coap/coap-engine.h"
/*---------------------------------------------------------------------------*/
#include <string.h>
/*---------------------------------------------------------------------------*/
static void

View File

@ -29,7 +29,7 @@
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup cc26xx-web-demo
* \addtogroup cc13xx-cc26xx-web-demo
* @{
*
* \file
@ -37,14 +37,13 @@
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "coap-engine.h"
#include "coap.h"
#include "net/ipv6/uip-ds6.h"
#include "net/app-layer/coap/coap.h"
#include "net/app-layer/coap/coap-engine.h"
/*---------------------------------------------------------------------------*/
#include "coap-server.h"
#include "cc26xx-web-demo.h"
#include "ti-lib.h"
#include "web-demo.h"
/*---------------------------------------------------------------------------*/
#include <string.h>
#include <stdio.h>
/*---------------------------------------------------------------------------*/
@ -94,7 +93,7 @@ res_get_handler_pref_parent(coap_message_t *request, coap_message_t *response,
coap_get_header_accept(request, &accept);
memset(def_rt_str, 0, sizeof(def_rt_str));
cc26xx_web_demo_ipaddr_sprintf(def_rt_str, sizeof(def_rt_str),
web_demo_ipaddr_sprintf(def_rt_str, sizeof(def_rt_str),
uip_ds6_defrt_choose());
if(accept == -1 || accept == TEXT_PLAIN) {

View File

@ -29,19 +29,20 @@
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup cc26xx-web-demo
* \addtogroup cc13xx-cc26xx-web-demo
* @{
*
* \file
* CoAP resource handler for the Sensortag-CC26xx sensors
* CoAP resource handler for the Sensortag sensors
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "coap-engine.h"
#include "coap.h"
#include "cc26xx-web-demo.h"
#include "net/app-layer/coap/coap.h"
#include "net/app-layer/coap/coap-engine.h"
/*---------------------------------------------------------------------------*/
#include "web-demo.h"
#include "coap-server.h"
/*---------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdint.h>
#include <string.h>
@ -56,9 +57,9 @@ res_get_handler_all(int sens_type, coap_message_t *request,
uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
unsigned int accept = -1;
const cc26xx_web_demo_sensor_reading_t *reading;
const web_demo_sensor_reading_t *reading;
reading = cc26xx_web_demo_sensor_lookup(sens_type);
reading = web_demo_sensor_lookup(sens_type);
if(reading == NULL) {
coap_set_status_code(response, NOT_FOUND_4_04);
@ -101,7 +102,7 @@ res_get_handler_batmon_temp(coap_message_t *request, coap_message_t *response,
uint8_t *buffer,
uint16_t preferred_size, int32_t *offset)
{
res_get_handler_all(CC26XX_WEB_DEMO_SENSOR_BATMON_TEMP, request, response,
res_get_handler_all(WEB_DEMO_SENSOR_BATMON_TEMP, request, response,
buffer, preferred_size, offset);
}
/*---------------------------------------------------------------------------*/
@ -110,7 +111,7 @@ res_get_handler_batmon_volt(coap_message_t *request, coap_message_t *response,
uint8_t *buffer,
uint16_t preferred_size, int32_t *offset)
{
res_get_handler_all(CC26XX_WEB_DEMO_SENSOR_BATMON_VOLT, request, response,
res_get_handler_all(WEB_DEMO_SENSOR_BATMON_VOLT, request, response,
buffer, preferred_size, offset);
}
/*---------------------------------------------------------------------------*/
@ -120,14 +121,14 @@ RESOURCE(res_batmon_temp, "title=\"Battery Temp\";rt=\"C\"",
RESOURCE(res_batmon_volt, "title=\"Battery Voltage\";rt=\"mV\"",
res_get_handler_batmon_volt, NULL, NULL, NULL);
/*---------------------------------------------------------------------------*/
#if CC26XX_WEB_DEMO_ADC_DEMO
#if WEB_DEMO_ADC_DEMO
/*---------------------------------------------------------------------------*/
static void
res_get_handler_adc_dio23(coap_message_t *request, coap_message_t *response,
uint8_t *buffer,
uint16_t preferred_size, int32_t *offset)
{
res_get_handler_all(CC26XX_WEB_DEMO_SENSOR_ADC_DIO23, request, response,
res_get_handler_all(WEB_DEMO_SENSOR_ADC_DIO23, request, response,
buffer, preferred_size, offset);
}
/*---------------------------------------------------------------------------*/
@ -144,7 +145,7 @@ res_get_handler_mpu_acc_x(coap_message_t *request, coap_message_t *response,
uint8_t *buffer,
uint16_t preferred_size, int32_t *offset)
{
res_get_handler_all(CC26XX_WEB_DEMO_SENSOR_MPU_ACC_X, request, response,
res_get_handler_all(WEB_DEMO_SENSOR_MPU_ACC_X, request, response,
buffer, preferred_size, offset);
}
/*---------------------------------------------------------------------------*/
@ -153,7 +154,7 @@ res_get_handler_mpu_acc_y(coap_message_t *request, coap_message_t *response,
uint8_t *buffer,
uint16_t preferred_size, int32_t *offset)
{
res_get_handler_all(CC26XX_WEB_DEMO_SENSOR_MPU_ACC_Y, request, response,
res_get_handler_all(WEB_DEMO_SENSOR_MPU_ACC_Y, request, response,
buffer, preferred_size, offset);
}
/*---------------------------------------------------------------------------*/
@ -162,7 +163,7 @@ res_get_handler_mpu_acc_z(coap_message_t *request, coap_message_t *response,
uint8_t *buffer,
uint16_t preferred_size, int32_t *offset)
{
res_get_handler_all(CC26XX_WEB_DEMO_SENSOR_MPU_ACC_Z, request, response,
res_get_handler_all(WEB_DEMO_SENSOR_MPU_ACC_Z, request, response,
buffer, preferred_size, offset);
}
/*---------------------------------------------------------------------------*/
@ -171,7 +172,7 @@ res_get_handler_mpu_gyro_x(coap_message_t *request, coap_message_t *response,
uint8_t *buffer,
uint16_t preferred_size, int32_t *offset)
{
res_get_handler_all(CC26XX_WEB_DEMO_SENSOR_MPU_GYRO_X, request, response,
res_get_handler_all(WEB_DEMO_SENSOR_MPU_GYRO_X, request, response,
buffer, preferred_size, offset);
}
/*---------------------------------------------------------------------------*/
@ -180,7 +181,7 @@ res_get_handler_mpu_gyro_y(coap_message_t *request, coap_message_t *response,
uint8_t *buffer,
uint16_t preferred_size, int32_t *offset)
{
res_get_handler_all(CC26XX_WEB_DEMO_SENSOR_MPU_GYRO_Y, request, response,
res_get_handler_all(WEB_DEMO_SENSOR_MPU_GYRO_Y, request, response,
buffer, preferred_size, offset);
}
/*---------------------------------------------------------------------------*/
@ -189,7 +190,7 @@ res_get_handler_mpu_gyro_z(coap_message_t *request, coap_message_t *response,
uint8_t *buffer,
uint16_t preferred_size, int32_t *offset)
{
res_get_handler_all(CC26XX_WEB_DEMO_SENSOR_MPU_GYRO_Z, request, response,
res_get_handler_all(WEB_DEMO_SENSOR_MPU_GYRO_Z, request, response,
buffer, preferred_size, offset);
}
/*---------------------------------------------------------------------------*/
@ -213,7 +214,7 @@ res_get_handler_obj_temp(coap_message_t *request, coap_message_t *response,
uint8_t *buffer,
uint16_t preferred_size, int32_t *offset)
{
res_get_handler_all(CC26XX_WEB_DEMO_SENSOR_TMP_OBJECT, request, response,
res_get_handler_all(WEB_DEMO_SENSOR_TMP_OBJECT, request, response,
buffer, preferred_size, offset);
}
/*---------------------------------------------------------------------------*/
@ -222,7 +223,7 @@ res_get_handler_amb_temp(coap_message_t *request, coap_message_t *response,
uint8_t *buffer,
uint16_t preferred_size, int32_t *offset)
{
res_get_handler_all(CC26XX_WEB_DEMO_SENSOR_TMP_AMBIENT, request, response,
res_get_handler_all(WEB_DEMO_SENSOR_TMP_AMBIENT, request, response,
buffer, preferred_size, offset);
}
/*---------------------------------------------------------------------------*/
@ -238,7 +239,7 @@ res_get_handler_bmp_temp(coap_message_t *request, coap_message_t *response,
uint8_t *buffer,
uint16_t preferred_size, int32_t *offset)
{
res_get_handler_all(CC26XX_WEB_DEMO_SENSOR_BMP_TEMP, request, response,
res_get_handler_all(WEB_DEMO_SENSOR_BMP_TEMP, request, response,
buffer, preferred_size, offset);
}
/*---------------------------------------------------------------------------*/
@ -247,7 +248,7 @@ res_get_handler_bmp_press(coap_message_t *request, coap_message_t *response,
uint8_t *buffer,
uint16_t preferred_size, int32_t *offset)
{
res_get_handler_all(CC26XX_WEB_DEMO_SENSOR_BMP_PRES, request, response,
res_get_handler_all(WEB_DEMO_SENSOR_BMP_PRES, request, response,
buffer, preferred_size, offset);
}
/*---------------------------------------------------------------------------*/
@ -264,7 +265,7 @@ res_get_handler_hdc_temp(coap_message_t *request, coap_message_t *response,
uint8_t *buffer,
uint16_t preferred_size, int32_t *offset)
{
res_get_handler_all(CC26XX_WEB_DEMO_SENSOR_HDC_TEMP, request, response,
res_get_handler_all(WEB_DEMO_SENSOR_HDC_TEMP, request, response,
buffer, preferred_size, offset);
}
/*---------------------------------------------------------------------------*/
@ -273,7 +274,7 @@ res_get_handler_hdc_humidity(coap_message_t *request, coap_message_t *response,
uint8_t *buffer,
uint16_t preferred_size, int32_t *offset)
{
res_get_handler_all(CC26XX_WEB_DEMO_SENSOR_HDC_HUMIDITY, request, response,
res_get_handler_all(WEB_DEMO_SENSOR_HDC_HUMIDITY, request, response,
buffer, preferred_size, offset);
}
/*---------------------------------------------------------------------------*/
@ -289,7 +290,7 @@ res_get_handler_opt(coap_message_t *request, coap_message_t *response,
uint8_t *buffer,
uint16_t preferred_size, int32_t *offset)
{
res_get_handler_all(CC26XX_WEB_DEMO_SENSOR_OPT_LIGHT, request, response,
res_get_handler_all(WEB_DEMO_SENSOR_OPT_LIGHT, request, response,
buffer, preferred_size, offset);
}
/*---------------------------------------------------------------------------*/

View File

@ -31,7 +31,7 @@
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup cc26xx-web-demo
* \addtogroup cc13xx-cc26xx-web-demo
* @{
*
* \file
@ -42,9 +42,9 @@
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "coap-engine.h"
#include "dev/leds.h"
#include "net/app-layer/coap/coap-engine.h"
/*---------------------------------------------------------------------------*/
#include <string.h>
/*---------------------------------------------------------------------------*/
static void

View File

@ -28,39 +28,43 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup cc26xx-web-demo
* \addtogroup cc13xx-cc26xx-web-demo
* @{
*
* \file
* Main module for the CC26XX web demo. Activates on-device resources,
* Main module for the CC13xx/CC26xx web demo. Activates on-device resources,
* takes sensor readings periodically and caches them for all other modules
* to use.
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "contiki-net.h"
#include "coap-engine.h"
#include "board-peripherals.h"
#include "lib/sensors.h"
#include "lib/list.h"
#include "dev/button-hal.h"
#include "dev/ext-flash/ext-flash.h"
#include "sys/process.h"
#include "net/ipv6/sicslowpan.h"
#include "dev/button-hal.h"
#include "net/app-layer/coap/coap-engine.h"
#include "lib/sensors.h"
#include "lib/list.h"
/*---------------------------------------------------------------------------*/
#include <Board.h>
#include <ti/drivers/ADC.h>
/*---------------------------------------------------------------------------*/
#include "board-peripherals.h"
#include "batmon-sensor.h"
/*---------------------------------------------------------------------------*/
#include "web-demo.h"
#include "httpd-simple.h"
#include "cc26xx-web-demo.h"
#include "mqtt-client.h"
#include "coap-server.h"
/*---------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include "ti-lib.h"
/*---------------------------------------------------------------------------*/
PROCESS_NAME(cetic_6lbr_client_process);
PROCESS(cc26xx_web_demo_process, "CC26XX Web Demo");
PROCESS(web_demo_process, "CC13xx/CC26xx Web Demo");
/*---------------------------------------------------------------------------*/
/*
* Update sensor readings in a staggered fashion every SENSOR_READING_PERIOD
@ -76,101 +80,101 @@ struct ctimer bmp_timer, hdc_timer, tmp_timer, opt_timer, mpu_timer;
#endif
/*---------------------------------------------------------------------------*/
/* Provide visible feedback via LEDS while searching for a network */
#define NO_NET_LED_DURATION (CC26XX_WEB_DEMO_NET_CONNECT_PERIODIC >> 1)
#define NO_NET_LED_DURATION (WEB_DEMO_NET_CONNECT_PERIODIC >> 1)
static struct etimer et;
static struct ctimer ct;
/*---------------------------------------------------------------------------*/
/* Parent RSSI functionality */
#if CC26XX_WEB_DEMO_READ_PARENT_RSSI
#if WEB_DEMO_READ_PARENT_RSSI
static struct uip_icmp6_echo_reply_notification echo_reply_notification;
static struct etimer echo_request_timer;
int def_rt_rssi = 0;
#endif
/*---------------------------------------------------------------------------*/
#if CC26XX_WEB_DEMO_ADC_DEMO
#if WEB_DEMO_ADC_DEMO
PROCESS(adc_process, "ADC process");
static uint16_t single_adc_sample;
static uint_fast16_t single_adc_sample;
static struct etimer et_adc;
#endif
/*---------------------------------------------------------------------------*/
process_event_t cc26xx_web_demo_publish_event;
process_event_t cc26xx_web_demo_config_loaded_event;
process_event_t cc26xx_web_demo_load_config_defaults;
process_event_t web_demo_publish_event;
process_event_t web_demo_config_loaded_event;
process_event_t web_demo_load_config_defaults;
/*---------------------------------------------------------------------------*/
/* Saved settings on flash: store, offset, magic */
#define CONFIG_FLASH_OFFSET 0
#define CONFIG_MAGIC 0xCC265002
cc26xx_web_demo_config_t cc26xx_web_demo_config;
web_demo_config_t web_demo_config;
/*---------------------------------------------------------------------------*/
/* A cache of sensor values. Updated periodically or upon key press */
LIST(sensor_list);
/*---------------------------------------------------------------------------*/
/* The objects representing sensors used in this demo */
#define DEMO_SENSOR(name, type, descr, xml_element, form_field, units) \
cc26xx_web_demo_sensor_reading_t name##_reading = \
web_demo_sensor_reading_t name##_reading = \
{ NULL, 0, 0, descr, xml_element, form_field, units, type, 1, 1 }
/* CC26xx sensors */
DEMO_SENSOR(batmon_temp, CC26XX_WEB_DEMO_SENSOR_BATMON_TEMP,
/* CC13xx/CC26xx sensors */
DEMO_SENSOR(batmon_temp, WEB_DEMO_SENSOR_BATMON_TEMP,
"Battery Temp", "battery-temp", "batmon_temp",
CC26XX_WEB_DEMO_UNIT_TEMP);
DEMO_SENSOR(batmon_volt, CC26XX_WEB_DEMO_SENSOR_BATMON_VOLT,
WEB_DEMO_UNIT_TEMP);
DEMO_SENSOR(batmon_volt, WEB_DEMO_SENSOR_BATMON_VOLT,
"Battery Volt", "battery-volt", "batmon_volt",
CC26XX_WEB_DEMO_UNIT_VOLT);
WEB_DEMO_UNIT_VOLT);
#if CC26XX_WEB_DEMO_ADC_DEMO
DEMO_SENSOR(adc_dio23, CC26XX_WEB_DEMO_SENSOR_ADC_DIO23,
#if WEB_DEMO_ADC_DEMO
DEMO_SENSOR(adc_dio23, WEB_DEMO_SENSOR_ADC_DIO23,
"ADC DIO23", "adc-dio23", "adc_dio23",
CC26XX_WEB_DEMO_UNIT_VOLT);
WEB_DEMO_UNIT_VOLT);
#endif
/* Sensortag sensors */
#if BOARD_SENSORTAG
DEMO_SENSOR(bmp_pres, CC26XX_WEB_DEMO_SENSOR_BMP_PRES,
DEMO_SENSOR(bmp_pres, WEB_DEMO_SENSOR_BMP_PRES,
"Air Pressure", "air-pressure", "bmp_pres",
CC26XX_WEB_DEMO_UNIT_PRES);
DEMO_SENSOR(bmp_temp, CC26XX_WEB_DEMO_SENSOR_BMP_TEMP,
WEB_DEMO_UNIT_PRES);
DEMO_SENSOR(bmp_temp, WEB_DEMO_SENSOR_BMP_TEMP,
"Air Temp", "air-temp", "bmp_temp",
CC26XX_WEB_DEMO_UNIT_TEMP);
DEMO_SENSOR(hdc_temp, CC26XX_WEB_DEMO_SENSOR_HDC_TEMP,
WEB_DEMO_UNIT_TEMP);
DEMO_SENSOR(hdc_temp, WEB_DEMO_SENSOR_HDC_TEMP,
"HDC Temp", "hdc-temp", "hdc_temp",
CC26XX_WEB_DEMO_UNIT_TEMP);
DEMO_SENSOR(hdc_hum, CC26XX_WEB_DEMO_SENSOR_HDC_HUMIDITY,
WEB_DEMO_UNIT_TEMP);
DEMO_SENSOR(hdc_hum, WEB_DEMO_SENSOR_HDC_HUMIDITY,
"HDC Humidity", "hdc-humidity", "hdc_hum",
CC26XX_WEB_DEMO_UNIT_HUMIDITY);
DEMO_SENSOR(tmp_amb, CC26XX_WEB_DEMO_SENSOR_TMP_AMBIENT,
WEB_DEMO_UNIT_HUMIDITY);
DEMO_SENSOR(tmp_amb, WEB_DEMO_SENSOR_TMP_AMBIENT,
"Ambient Temp", "ambient-temp", "tmp_amb",
CC26XX_WEB_DEMO_UNIT_TEMP);
DEMO_SENSOR(tmp_obj, CC26XX_WEB_DEMO_SENSOR_TMP_OBJECT,
WEB_DEMO_UNIT_TEMP);
DEMO_SENSOR(tmp_obj, WEB_DEMO_SENSOR_TMP_OBJECT,
"Object Temp", "object-temp", "tmp_obj",
CC26XX_WEB_DEMO_UNIT_TEMP);
DEMO_SENSOR(opt, CC26XX_WEB_DEMO_SENSOR_OPT_LIGHT,
WEB_DEMO_UNIT_TEMP);
DEMO_SENSOR(opt, WEB_DEMO_SENSOR_OPT_LIGHT,
"Light", "light", "light",
CC26XX_WEB_DEMO_UNIT_LIGHT);
WEB_DEMO_UNIT_LIGHT);
/* MPU Readings */
DEMO_SENSOR(mpu_acc_x, CC26XX_WEB_DEMO_SENSOR_MPU_ACC_X,
DEMO_SENSOR(mpu_acc_x, WEB_DEMO_SENSOR_MPU_ACC_X,
"Acc X", "acc-x", "acc_x",
CC26XX_WEB_DEMO_UNIT_ACC);
DEMO_SENSOR(mpu_acc_y, CC26XX_WEB_DEMO_SENSOR_MPU_ACC_Y,
WEB_DEMO_UNIT_ACC);
DEMO_SENSOR(mpu_acc_y, WEB_DEMO_SENSOR_MPU_ACC_Y,
"Acc Y", "acc-y", "acc_y",
CC26XX_WEB_DEMO_UNIT_ACC);
DEMO_SENSOR(mpu_acc_z, CC26XX_WEB_DEMO_SENSOR_MPU_ACC_Z,
WEB_DEMO_UNIT_ACC);
DEMO_SENSOR(mpu_acc_z, WEB_DEMO_SENSOR_MPU_ACC_Z,
"Acc Z", "acc-z", "acc_z",
CC26XX_WEB_DEMO_UNIT_ACC);
WEB_DEMO_UNIT_ACC);
DEMO_SENSOR(mpu_gyro_x, CC26XX_WEB_DEMO_SENSOR_MPU_GYRO_X,
DEMO_SENSOR(mpu_gyro_x, WEB_DEMO_SENSOR_MPU_GYRO_X,
"Gyro X", "gyro-x", "gyro_x",
CC26XX_WEB_DEMO_UNIT_GYRO);
DEMO_SENSOR(mpu_gyro_y, CC26XX_WEB_DEMO_SENSOR_MPU_GYRO_Y,
WEB_DEMO_UNIT_GYRO);
DEMO_SENSOR(mpu_gyro_y, WEB_DEMO_SENSOR_MPU_GYRO_Y,
"Gyro Y", "gyro-y", "gyro_y",
CC26XX_WEB_DEMO_UNIT_GYRO);
DEMO_SENSOR(mpu_gyro_z, CC26XX_WEB_DEMO_SENSOR_MPU_GYRO_Z,
WEB_DEMO_UNIT_GYRO);
DEMO_SENSOR(mpu_gyro_z, WEB_DEMO_SENSOR_MPU_GYRO_Z,
"Gyro Z", "gyro-z", "gyro_Z",
CC26XX_WEB_DEMO_UNIT_GYRO);
WEB_DEMO_UNIT_GYRO);
#endif
/*---------------------------------------------------------------------------*/
#if BOARD_SENSORTAG
@ -184,7 +188,7 @@ static void init_mpu_reading(void *data);
static void
publish_led_off(void *d)
{
leds_off(CC26XX_WEB_DEMO_STATUS_LED);
leds_off(WEB_DEMO_STATUS_LED);
}
/*---------------------------------------------------------------------------*/
static void
@ -193,7 +197,7 @@ save_config()
/* Dump current running config to flash */
#if BOARD_SENSORTAG || BOARD_LAUNCHPAD
int rv;
cc26xx_web_demo_sensor_reading_t *reading = NULL;
web_demo_sensor_reading_t *reading = NULL;
rv = ext_flash_open(NULL);
@ -203,25 +207,25 @@ save_config()
return;
}
rv = ext_flash_erase(NULL, CONFIG_FLASH_OFFSET, sizeof(cc26xx_web_demo_config_t));
rv = ext_flash_erase(NULL, CONFIG_FLASH_OFFSET, sizeof(web_demo_config_t));
if(!rv) {
printf("Error erasing flash\n");
} else {
cc26xx_web_demo_config.magic = CONFIG_MAGIC;
cc26xx_web_demo_config.len = sizeof(cc26xx_web_demo_config_t);
cc26xx_web_demo_config.sensors_bitmap = 0;
web_demo_config.magic = CONFIG_MAGIC;
web_demo_config.len = sizeof(web_demo_config_t);
web_demo_config.sensors_bitmap = 0;
for(reading = list_head(sensor_list);
reading != NULL;
reading = list_item_next(reading)) {
if(reading->publish) {
cc26xx_web_demo_config.sensors_bitmap |= (1 << reading->type);
web_demo_config.sensors_bitmap |= (1 << reading->type);
}
}
rv = ext_flash_write(NULL, CONFIG_FLASH_OFFSET, sizeof(cc26xx_web_demo_config_t),
(uint8_t *)&cc26xx_web_demo_config);
rv = ext_flash_write(NULL, CONFIG_FLASH_OFFSET, sizeof(web_demo_config_t),
(uint8_t *)&web_demo_config);
if(!rv) {
printf("Error saving config\n");
}
@ -236,8 +240,8 @@ load_config()
{
#if BOARD_SENSORTAG || BOARD_LAUNCHPAD
/* Read from flash into a temp buffer */
cc26xx_web_demo_config_t tmp_cfg;
cc26xx_web_demo_sensor_reading_t *reading = NULL;
web_demo_config_t tmp_cfg;
web_demo_sensor_reading_t *reading = NULL;
int rv = ext_flash_open(NULL);
@ -258,27 +262,27 @@ load_config()
}
if(tmp_cfg.magic == CONFIG_MAGIC && tmp_cfg.len == sizeof(tmp_cfg)) {
memcpy(&cc26xx_web_demo_config, &tmp_cfg, sizeof(cc26xx_web_demo_config));
memcpy(&web_demo_config, &tmp_cfg, sizeof(web_demo_config));
}
for(reading = list_head(sensor_list);
reading != NULL;
reading = list_item_next(reading)) {
if(cc26xx_web_demo_config.sensors_bitmap & (1 << reading->type)) {
if(web_demo_config.sensors_bitmap & (1 << reading->type)) {
reading->publish = 1;
} else {
reading->publish = 0;
snprintf(reading->converted, CC26XX_WEB_DEMO_CONVERTED_LEN, "\"N/A\"");
snprintf(reading->converted, WEB_DEMO_CONVERTED_LEN, "\"N/A\"");
}
}
#endif
}
/*---------------------------------------------------------------------------*/
/* Don't start everything here, we need to dictate order of initialisation */
AUTOSTART_PROCESSES(&cc26xx_web_demo_process);
AUTOSTART_PROCESSES(&web_demo_process);
/*---------------------------------------------------------------------------*/
int
cc26xx_web_demo_ipaddr_sprintf(char *buf, uint8_t buf_len,
web_demo_ipaddr_sprintf(char *buf, uint8_t buf_len,
const uip_ipaddr_t *addr)
{
uint16_t a;
@ -303,10 +307,10 @@ cc26xx_web_demo_ipaddr_sprintf(char *buf, uint8_t buf_len,
return len;
}
/*---------------------------------------------------------------------------*/
const cc26xx_web_demo_sensor_reading_t *
cc26xx_web_demo_sensor_lookup(int sens_type)
const web_demo_sensor_reading_t *
web_demo_sensor_lookup(int sens_type)
{
cc26xx_web_demo_sensor_reading_t *reading = NULL;
web_demo_sensor_reading_t *reading = NULL;
for(reading = list_head(sensor_list);
reading != NULL;
@ -319,16 +323,16 @@ cc26xx_web_demo_sensor_lookup(int sens_type)
return NULL;
}
/*---------------------------------------------------------------------------*/
const cc26xx_web_demo_sensor_reading_t *
cc26xx_web_demo_sensor_first()
const web_demo_sensor_reading_t *
web_demo_sensor_first()
{
return list_head(sensor_list);
}
/*---------------------------------------------------------------------------*/
void
cc26xx_web_demo_restore_defaults(void)
web_demo_restore_defaults(void)
{
cc26xx_web_demo_sensor_reading_t *reading = NULL;
web_demo_sensor_reading_t *reading = NULL;
leds_on(LEDS_ALL);
@ -338,13 +342,13 @@ cc26xx_web_demo_restore_defaults(void)
reading->publish = 1;
}
#if CC26XX_WEB_DEMO_MQTT_CLIENT
#if WEB_DEMO_MQTT_CLIENT
process_post_synch(&mqtt_client_process,
cc26xx_web_demo_load_config_defaults, NULL);
web_demo_load_config_defaults, NULL);
#endif
#if CC26XX_WEB_DEMO_NET_UART
process_post_synch(&net_uart_process, cc26xx_web_demo_load_config_defaults,
#if WEB_DEMO_NET_UART
process_post_synch(&net_uart_process, web_demo_load_config_defaults,
NULL);
#endif
@ -362,7 +366,7 @@ defaults_post_handler(char *key, int key_len, char *val, int val_len)
return HTTPD_SIMPLE_POST_HANDLER_UNKNOWN;
}
cc26xx_web_demo_restore_defaults();
web_demo_restore_defaults();
return HTTPD_SIMPLE_POST_HANDLER_OK;
}
@ -370,7 +374,7 @@ defaults_post_handler(char *key, int key_len, char *val, int val_len)
static int
sensor_readings_handler(char *key, int key_len, char *val, int val_len)
{
cc26xx_web_demo_sensor_reading_t *reading = NULL;
web_demo_sensor_reading_t *reading = NULL;
int rv;
for(reading = list_head(sensor_list);
@ -384,7 +388,7 @@ sensor_readings_handler(char *key, int key_len, char *val, int val_len)
/* Be pedantic: only accept 0 and 1, not just any non-zero value */
if(rv == 0) {
reading->publish = 0;
snprintf(reading->converted, CC26XX_WEB_DEMO_CONVERTED_LEN, "\"N/A\"");
snprintf(reading->converted, WEB_DEMO_CONVERTED_LEN, "\"N/A\"");
} else if(rv == 1) {
reading->publish = 1;
} else {
@ -398,7 +402,7 @@ sensor_readings_handler(char *key, int key_len, char *val, int val_len)
return HTTPD_SIMPLE_POST_HANDLER_UNKNOWN;
}
/*---------------------------------------------------------------------------*/
#if CC26XX_WEB_DEMO_READ_PARENT_RSSI
#if WEB_DEMO_READ_PARENT_RSSI
static int
ping_interval_post_handler(char *key, int key_len, char *val, int val_len)
{
@ -412,12 +416,12 @@ ping_interval_post_handler(char *key, int key_len, char *val, int val_len)
rv = atoi(val);
if(rv < CC26XX_WEB_DEMO_RSSI_MEASURE_INTERVAL_MIN ||
rv > CC26XX_WEB_DEMO_RSSI_MEASURE_INTERVAL_MAX) {
if(rv < WEB_DEMO_RSSI_MEASURE_INTERVAL_MIN ||
rv > WEB_DEMO_RSSI_MEASURE_INTERVAL_MAX) {
return HTTPD_SIMPLE_POST_HANDLER_ERROR;
}
cc26xx_web_demo_config.def_rt_ping_interval = rv * CLOCK_SECOND;
web_demo_config.def_rt_ping_interval = rv * CLOCK_SECOND;
return HTTPD_SIMPLE_POST_HANDLER_OK;
}
@ -426,7 +430,7 @@ ping_interval_post_handler(char *key, int key_len, char *val, int val_len)
HTTPD_SIMPLE_POST_HANDLER(sensor, sensor_readings_handler);
HTTPD_SIMPLE_POST_HANDLER(defaults, defaults_post_handler);
#if CC26XX_WEB_DEMO_READ_PARENT_RSSI
#if WEB_DEMO_READ_PARENT_RSSI
HTTPD_SIMPLE_POST_HANDLER(ping_interval, ping_interval_post_handler);
/*---------------------------------------------------------------------------*/
static void
@ -446,7 +450,7 @@ ping_parent(void)
}
uip_icmp6_send(uip_ds6_defrt_choose(), ICMP6_ECHO_REQUEST, 0,
CC26XX_WEB_DEMO_ECHO_REQ_PAYLOAD_LEN);
WEB_DEMO_ECHO_REQ_PAYLOAD_LEN);
}
#endif
/*---------------------------------------------------------------------------*/
@ -460,30 +464,30 @@ get_batmon_reading(void *data)
if(batmon_temp_reading.publish) {
value = batmon_sensor.value(BATMON_SENSOR_TYPE_TEMP);
if(value != CC26XX_SENSOR_READING_ERROR) {
if(value != BATMON_SENSOR_READING_ERROR) {
batmon_temp_reading.raw = value;
buf = batmon_temp_reading.converted;
memset(buf, 0, CC26XX_WEB_DEMO_CONVERTED_LEN);
snprintf(buf, CC26XX_WEB_DEMO_CONVERTED_LEN, "%d", value);
memset(buf, 0, WEB_DEMO_CONVERTED_LEN);
snprintf(buf, WEB_DEMO_CONVERTED_LEN, "%d", value);
}
}
if(batmon_volt_reading.publish) {
value = batmon_sensor.value(BATMON_SENSOR_TYPE_VOLT);
if(value != CC26XX_SENSOR_READING_ERROR) {
if(value != BATMON_SENSOR_READING_ERROR) {
batmon_volt_reading.raw = value;
buf = batmon_volt_reading.converted;
memset(buf, 0, CC26XX_WEB_DEMO_CONVERTED_LEN);
snprintf(buf, CC26XX_WEB_DEMO_CONVERTED_LEN, "%d", (value * 125) >> 5);
memset(buf, 0, WEB_DEMO_CONVERTED_LEN);
snprintf(buf, WEB_DEMO_CONVERTED_LEN, "%d", (value * 125) >> 5);
}
}
ctimer_set(&batmon_timer, next, get_batmon_reading, NULL);
}
/*---------------------------------------------------------------------------*/
#if CC26XX_WEB_DEMO_ADC_DEMO
#if WEB_DEMO_ADC_DEMO
static void
get_adc_reading(void *data)
{
@ -493,8 +497,8 @@ get_adc_reading(void *data)
if(adc_dio23_reading.publish) {
value = single_adc_sample;
buf = adc_dio23_reading.converted;
memset(buf, 0, CC26XX_WEB_DEMO_CONVERTED_LEN);
snprintf(buf, CC26XX_WEB_DEMO_CONVERTED_LEN, "%d", (value * 4300) >> 12);
memset(buf, 0, WEB_DEMO_CONVERTED_LEN);
snprintf(buf, WEB_DEMO_CONVERTED_LEN, "%d", (value * 4300) >> 12);
}
}
#endif
@ -502,7 +506,7 @@ get_adc_reading(void *data)
#if BOARD_SENSORTAG
/*---------------------------------------------------------------------------*/
static void
compare_and_update(cc26xx_web_demo_sensor_reading_t *reading)
compare_and_update(web_demo_sensor_reading_t *reading)
{
if(reading->last == reading->raw) {
reading->changed = 0;
@ -536,28 +540,28 @@ get_bmp_reading()
if(bmp_pres_reading.publish) {
value = bmp_280_sensor.value(BMP_280_SENSOR_TYPE_PRESS);
if(value != CC26XX_SENSOR_READING_ERROR) {
if(value != BMP_280_READING_ERROR) {
bmp_pres_reading.raw = value;
compare_and_update(&bmp_pres_reading);
buf = bmp_pres_reading.converted;
memset(buf, 0, CC26XX_WEB_DEMO_CONVERTED_LEN);
snprintf(buf, CC26XX_WEB_DEMO_CONVERTED_LEN, "%d.%02d", value / 100,
memset(buf, 0, WEB_DEMO_CONVERTED_LEN);
snprintf(buf, WEB_DEMO_CONVERTED_LEN, "%d.%02d", value / 100,
value % 100);
}
}
if(bmp_temp_reading.publish) {
value = bmp_280_sensor.value(BMP_280_SENSOR_TYPE_TEMP);
if(value != CC26XX_SENSOR_READING_ERROR) {
if(value != BMP_280_READING_ERROR) {
bmp_temp_reading.raw = value;
compare_and_update(&bmp_temp_reading);
buf = bmp_temp_reading.converted;
memset(buf, 0, CC26XX_WEB_DEMO_CONVERTED_LEN);
snprintf(buf, CC26XX_WEB_DEMO_CONVERTED_LEN, "%d.%02d", value / 100,
memset(buf, 0, WEB_DEMO_CONVERTED_LEN);
snprintf(buf, WEB_DEMO_CONVERTED_LEN, "%d.%02d", value / 100,
value % 100);
}
}
@ -577,7 +581,7 @@ get_tmp_reading()
if(tmp_amb_reading.publish || tmp_obj_reading.publish) {
if(tmp_007_sensor.value(TMP_007_SENSOR_TYPE_ALL) ==
CC26XX_SENSOR_READING_ERROR) {
TMP_007_READING_ERROR) {
SENSORS_DEACTIVATE(tmp_007_sensor);
ctimer_set(&tmp_timer, next, init_tmp_reading, NULL);
@ -591,8 +595,8 @@ get_tmp_reading()
compare_and_update(&tmp_amb_reading);
buf = tmp_amb_reading.converted;
memset(buf, 0, CC26XX_WEB_DEMO_CONVERTED_LEN);
snprintf(buf, CC26XX_WEB_DEMO_CONVERTED_LEN, "%d.%03d", value / 1000,
memset(buf, 0, WEB_DEMO_CONVERTED_LEN);
snprintf(buf, WEB_DEMO_CONVERTED_LEN, "%d.%03d", value / 1000,
value % 1000);
}
@ -603,8 +607,8 @@ get_tmp_reading()
compare_and_update(&tmp_obj_reading);
buf = tmp_obj_reading.converted;
memset(buf, 0, CC26XX_WEB_DEMO_CONVERTED_LEN);
snprintf(buf, CC26XX_WEB_DEMO_CONVERTED_LEN, "%d.%03d", value / 1000,
memset(buf, 0, WEB_DEMO_CONVERTED_LEN);
snprintf(buf, WEB_DEMO_CONVERTED_LEN, "%d.%03d", value / 1000,
value % 1000);
}
@ -623,28 +627,28 @@ get_hdc_reading()
if(hdc_temp_reading.publish) {
value = hdc_1000_sensor.value(HDC_1000_SENSOR_TYPE_TEMP);
if(value != CC26XX_SENSOR_READING_ERROR) {
if(value != HDC_1000_READING_ERROR) {
hdc_temp_reading.raw = value;
compare_and_update(&hdc_temp_reading);
buf = hdc_temp_reading.converted;
memset(buf, 0, CC26XX_WEB_DEMO_CONVERTED_LEN);
snprintf(buf, CC26XX_WEB_DEMO_CONVERTED_LEN, "%d.%02d", value / 100,
memset(buf, 0, WEB_DEMO_CONVERTED_LEN);
snprintf(buf, WEB_DEMO_CONVERTED_LEN, "%d.%02d", value / 100,
value % 100);
}
}
if(hdc_hum_reading.publish) {
value = hdc_1000_sensor.value(HDC_1000_SENSOR_TYPE_HUMIDITY);
if(value != CC26XX_SENSOR_READING_ERROR) {
if(value != HDC_1000_READING_ERROR) {
hdc_hum_reading.raw = value;
compare_and_update(&hdc_hum_reading);
buf = hdc_hum_reading.converted;
memset(buf, 0, CC26XX_WEB_DEMO_CONVERTED_LEN);
snprintf(buf, CC26XX_WEB_DEMO_CONVERTED_LEN, "%d.%02d", value / 100,
memset(buf, 0, WEB_DEMO_CONVERTED_LEN);
snprintf(buf, WEB_DEMO_CONVERTED_LEN, "%d.%02d", value / 100,
value % 100);
}
}
@ -662,14 +666,14 @@ get_light_reading()
value = opt_3001_sensor.value(0);
if(value != CC26XX_SENSOR_READING_ERROR) {
if(value != OPT_3001_READING_ERROR) {
opt_reading.raw = value;
compare_and_update(&opt_reading);
buf = opt_reading.converted;
memset(buf, 0, CC26XX_WEB_DEMO_CONVERTED_LEN);
snprintf(buf, CC26XX_WEB_DEMO_CONVERTED_LEN, "%d.%02d", value / 100,
memset(buf, 0, WEB_DEMO_CONVERTED_LEN);
snprintf(buf, WEB_DEMO_CONVERTED_LEN, "%d.%02d", value / 100,
value % 100);
}
@ -686,42 +690,42 @@ get_mpu_reading()
if(mpu_gyro_x_reading.publish) {
raw = mpu_9250_sensor.value(MPU_9250_SENSOR_TYPE_GYRO_X);
if(raw != CC26XX_SENSOR_READING_ERROR) {
if(raw != MPU_9250_READING_ERROR) {
mpu_gyro_x_reading.raw = raw;
}
}
if(mpu_gyro_y_reading.publish) {
raw = mpu_9250_sensor.value(MPU_9250_SENSOR_TYPE_GYRO_Y);
if(raw != CC26XX_SENSOR_READING_ERROR) {
if(raw != MPU_9250_READING_ERROR) {
mpu_gyro_y_reading.raw = raw;
}
}
if(mpu_gyro_z_reading.publish) {
raw = mpu_9250_sensor.value(MPU_9250_SENSOR_TYPE_GYRO_Z);
if(raw != CC26XX_SENSOR_READING_ERROR) {
if(raw != MPU_9250_READING_ERROR) {
mpu_gyro_z_reading.raw = raw;
}
}
if(mpu_acc_x_reading.publish) {
raw = mpu_9250_sensor.value(MPU_9250_SENSOR_TYPE_ACC_X);
if(raw != CC26XX_SENSOR_READING_ERROR) {
if(raw != MPU_9250_READING_ERROR) {
mpu_acc_x_reading.raw = raw;
}
}
if(mpu_acc_y_reading.publish) {
raw = mpu_9250_sensor.value(MPU_9250_SENSOR_TYPE_ACC_Y);
if(raw != CC26XX_SENSOR_READING_ERROR) {
if(raw != MPU_9250_READING_ERROR) {
mpu_acc_y_reading.raw = raw;
}
}
if(mpu_acc_z_reading.publish) {
raw = mpu_9250_sensor.value(MPU_9250_SENSOR_TYPE_ACC_Z);
if(raw != CC26XX_SENSOR_READING_ERROR) {
if(raw != MPU_9250_READING_ERROR) {
mpu_acc_z_reading.raw = raw;
}
}
@ -730,37 +734,37 @@ get_mpu_reading()
if(mpu_gyro_x_reading.publish) {
compare_and_update(&mpu_gyro_x_reading);
memset(mpu_gyro_x_reading.converted, 0, CC26XX_WEB_DEMO_CONVERTED_LEN);
memset(mpu_gyro_x_reading.converted, 0, WEB_DEMO_CONVERTED_LEN);
print_mpu_reading(mpu_gyro_x_reading.raw, mpu_gyro_x_reading.converted);
}
if(mpu_gyro_y_reading.publish) {
compare_and_update(&mpu_gyro_y_reading);
memset(mpu_gyro_y_reading.converted, 0, CC26XX_WEB_DEMO_CONVERTED_LEN);
memset(mpu_gyro_y_reading.converted, 0, WEB_DEMO_CONVERTED_LEN);
print_mpu_reading(mpu_gyro_y_reading.raw, mpu_gyro_y_reading.converted);
}
if(mpu_gyro_z_reading.publish) {
compare_and_update(&mpu_gyro_z_reading);
memset(mpu_gyro_z_reading.converted, 0, CC26XX_WEB_DEMO_CONVERTED_LEN);
memset(mpu_gyro_z_reading.converted, 0, WEB_DEMO_CONVERTED_LEN);
print_mpu_reading(mpu_gyro_z_reading.raw, mpu_gyro_z_reading.converted);
}
if(mpu_acc_x_reading.publish) {
compare_and_update(&mpu_acc_x_reading);
memset(mpu_acc_x_reading.converted, 0, CC26XX_WEB_DEMO_CONVERTED_LEN);
memset(mpu_acc_x_reading.converted, 0, WEB_DEMO_CONVERTED_LEN);
print_mpu_reading(mpu_acc_x_reading.raw, mpu_acc_x_reading.converted);
}
if(mpu_acc_y_reading.publish) {
compare_and_update(&mpu_acc_y_reading);
memset(mpu_acc_y_reading.converted, 0, CC26XX_WEB_DEMO_CONVERTED_LEN);
memset(mpu_acc_y_reading.converted, 0, WEB_DEMO_CONVERTED_LEN);
print_mpu_reading(mpu_acc_y_reading.raw, mpu_acc_y_reading.converted);
}
if(mpu_acc_z_reading.publish) {
compare_and_update(&mpu_acc_z_reading);
memset(mpu_acc_z_reading.converted, 0, CC26XX_WEB_DEMO_CONVERTED_LEN);
memset(mpu_acc_z_reading.converted, 0, WEB_DEMO_CONVERTED_LEN);
print_mpu_reading(mpu_acc_z_reading.raw, mpu_acc_z_reading.converted);
}
@ -858,7 +862,7 @@ init_sensors(void)
list_add(sensor_list, &batmon_temp_reading);
list_add(sensor_list, &batmon_volt_reading);
#if CC26XX_WEB_DEMO_ADC_DEMO
#if WEB_DEMO_ADC_DEMO
list_add(sensor_list, &adc_dio23_reading);
#endif
@ -885,38 +889,38 @@ init_sensors(void)
#endif
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(cc26xx_web_demo_process, ev, data)
PROCESS_THREAD(web_demo_process, ev, data)
{
PROCESS_BEGIN();
printf("CC26XX Web Demo Process\n");
printf("CC13xx/CC26xx Web Demo Process\n");
init_sensors();
cc26xx_web_demo_publish_event = process_alloc_event();
cc26xx_web_demo_config_loaded_event = process_alloc_event();
cc26xx_web_demo_load_config_defaults = process_alloc_event();
web_demo_publish_event = process_alloc_event();
web_demo_config_loaded_event = process_alloc_event();
web_demo_load_config_defaults = process_alloc_event();
/* Start all other (enabled) processes first */
process_start(&httpd_simple_process, NULL);
#if CC26XX_WEB_DEMO_COAP_SERVER
#if WEB_DEMO_COAP_SERVER
process_start(&coap_server_process, NULL);
#endif
#if CC26XX_WEB_DEMO_6LBR_CLIENT
#if WEB_DEMO_6LBR_CLIENT
process_start(&cetic_6lbr_client_process, NULL);
#endif
#if CC26XX_WEB_DEMO_MQTT_CLIENT
#if WEB_DEMO_MQTT_CLIENT
process_start(&mqtt_client_process, NULL);
#endif
#if CC26XX_WEB_DEMO_NET_UART
#if WEB_DEMO_NET_UART
process_start(&net_uart_process, NULL);
#endif
#if CC26XX_WEB_DEMO_ADC_DEMO
#if WEB_DEMO_ADC_DEMO
process_start(&adc_process, NULL);
#endif
@ -924,32 +928,32 @@ PROCESS_THREAD(cc26xx_web_demo_process, ev, data)
* Now that processes have set their own config default values, set our
* own defaults and restore saved config from flash...
*/
cc26xx_web_demo_config.sensors_bitmap = 0xFFFFFFFF; /* all on by default */
cc26xx_web_demo_config.def_rt_ping_interval =
CC26XX_WEB_DEMO_DEFAULT_RSSI_MEAS_INTERVAL;
web_demo_config.sensors_bitmap = 0xFFFFFFFF; /* all on by default */
web_demo_config.def_rt_ping_interval =
WEB_DEMO_DEFAULT_RSSI_MEAS_INTERVAL;
load_config();
/*
* Notify all other processes (basically the ones in this demo) that the
* configuration has been loaded from flash, in case they care
*/
process_post(PROCESS_BROADCAST, cc26xx_web_demo_config_loaded_event, NULL);
process_post(PROCESS_BROADCAST, web_demo_config_loaded_event, NULL);
init_sensor_readings();
httpd_simple_register_post_handler(&sensor_handler);
httpd_simple_register_post_handler(&defaults_handler);
#if CC26XX_WEB_DEMO_READ_PARENT_RSSI
#if WEB_DEMO_READ_PARENT_RSSI
httpd_simple_register_post_handler(&ping_interval_handler);
def_rt_rssi = 0x8000000;
uip_icmp6_echo_reply_callback_add(&echo_reply_notification,
echo_reply_handler);
etimer_set(&echo_request_timer, CC26XX_WEB_DEMO_NET_CONNECT_PERIODIC);
etimer_set(&echo_request_timer, WEB_DEMO_NET_CONNECT_PERIODIC);
#endif
etimer_set(&et, CC26XX_WEB_DEMO_NET_CONNECT_PERIODIC);
etimer_set(&et, WEB_DEMO_NET_CONNECT_PERIODIC);
/*
* Update all sensor readings on a configurable sensors_event
@ -958,33 +962,33 @@ PROCESS_THREAD(cc26xx_web_demo_process, ev, data)
while(1) {
if(ev == PROCESS_EVENT_TIMER && etimer_expired(&et)) {
if(uip_ds6_get_global(ADDR_PREFERRED) == NULL) {
leds_on(CC26XX_WEB_DEMO_STATUS_LED);
leds_on(WEB_DEMO_STATUS_LED);
ctimer_set(&ct, NO_NET_LED_DURATION, publish_led_off, NULL);
etimer_set(&et, CC26XX_WEB_DEMO_NET_CONNECT_PERIODIC);
etimer_set(&et, WEB_DEMO_NET_CONNECT_PERIODIC);
}
}
#if CC26XX_WEB_DEMO_READ_PARENT_RSSI
#if WEB_DEMO_READ_PARENT_RSSI
if(ev == PROCESS_EVENT_TIMER && etimer_expired(&echo_request_timer)) {
if(uip_ds6_get_global(ADDR_PREFERRED) == NULL) {
etimer_set(&echo_request_timer, CC26XX_WEB_DEMO_NET_CONNECT_PERIODIC);
etimer_set(&echo_request_timer, WEB_DEMO_NET_CONNECT_PERIODIC);
} else {
ping_parent();
etimer_set(&echo_request_timer, cc26xx_web_demo_config.def_rt_ping_interval);
etimer_set(&echo_request_timer, web_demo_config.def_rt_ping_interval);
}
}
#endif
if(ev == button_hal_release_event &&
((button_hal_button_t *)data)->unique_id ==
CC26XX_WEB_DEMO_SENSOR_READING_TRIGGER) {
WEB_DEMO_SENSOR_READING_TRIGGER) {
init_sensor_readings();
process_post(PROCESS_BROADCAST, cc26xx_web_demo_publish_event, NULL);
process_post(PROCESS_BROADCAST, web_demo_publish_event, NULL);
} else if(ev == button_hal_periodic_event &&
((button_hal_button_t *)data)->unique_id ==
CC26XX_WEB_DEMO_SENSOR_READING_TRIGGER) {
WEB_DEMO_SENSOR_READING_TRIGGER) {
printf("Restoring defaults!\n");
cc26xx_web_demo_restore_defaults();
web_demo_restore_defaults();
} else if(ev == httpd_simple_event_new_config) {
save_config();
#if BOARD_SENSORTAG
@ -1007,48 +1011,36 @@ PROCESS_THREAD(cc26xx_web_demo_process, ev, data)
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
#if CC26XX_WEB_DEMO_ADC_DEMO
#if WEB_DEMO_ADC_DEMO
PROCESS_THREAD(adc_process, ev, data)
{
static ADC_Params adc_params;
ADC_Handle adc_handle;
int_fast16_t res;
uint_fast16_t adc_value;
PROCESS_BEGIN();
ADC_init();
ADC_Params_init(&adc_params);
etimer_set(&et_adc, CLOCK_SECOND * 5);
while(1) {
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et_adc));
/* intialisation of ADC */
ti_lib_aon_wuc_aux_wakeup_event(AONWUC_AUX_WAKEUP);
while(!(ti_lib_aon_wuc_power_status_get() & AONWUC_AUX_POWER_ON));
adc_handle = ADC_open(Board_ADC0, &adc_params);
/*
* Enable clock for ADC digital and analog interface (not currently enabled
* in driver)
*/
ti_lib_aux_wuc_clock_enable(AUX_WUC_ADI_CLOCK | AUX_WUC_ANAIF_CLOCK |
AUX_WUC_SMPH_CLOCK);
while(ti_lib_aux_wuc_clock_status(AUX_WUC_ADI_CLOCK | AUX_WUC_ANAIF_CLOCK |
AUX_WUC_SMPH_CLOCK)
!= AUX_WUC_CLOCK_READY);
if(adc_handle != NULL) {
res = ADC_convert(adc_handle, &single_adc_sample);
/* Connect AUX IO7 (DIO23, but also DP2 on XDS110) as analog input. */
ti_lib_aux_adc_select_input(ADC_COMPB_IN_AUXIO7);
if(res == ADC_STATUS_SUCCESS) {
single_adc_sample = adc_value;
get_adc_reading(NULL);
}
/* Set up ADC range, AUXADC_REF_FIXED = nominally 4.3 V */
ti_lib_aux_adc_enable_sync(AUXADC_REF_FIXED, AUXADC_SAMPLE_TIME_2P7_US,
AUXADC_TRIGGER_MANUAL);
/* Trigger ADC converting */
ti_lib_aux_adc_gen_manual_trigger();
/* Read value */
single_adc_sample = ti_lib_aux_adc_read_fifo();
/* Shut the adc down */
ti_lib_aux_adc_disable();
get_adc_reading(NULL);
ADC_close(adc_handle);
}
etimer_reset(&et_adc);
}

View File

@ -28,14 +28,14 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup cc26xx-examples
* \addtogroup cc13xx-cc26xx-examples
* @{
*
* \defgroup cc26xx-web-demo CC26xx Web Demo
* \defgroup cc13xx-cc26xx-web-demo CC13xx/CC26xx Web Demo
* @{
*
* An example demonstrating:
* * how to use a CC26XX-powered node in a deployment driven by a 6LBR
* * how to use a CC13xx/CC26xx-powered node in a deployment driven by a 6LBR
* * how to expose on-device sensors as CoAP resources
* * how to build a small web page which reports networking and sensory data
* * how to configure functionality through the aforementioned web page using
@ -43,93 +43,94 @@
* * a network-based UART
*
* \file
* Main header file for the CC26XX web demo.
* Main header file for the CC13xx/CC26xx web demo.
*/
/*---------------------------------------------------------------------------*/
#ifndef CC26XX_WEB_DEMO_H_
#define CC26XX_WEB_DEMO_H_
#ifndef WEB_DEMO_H_
#define WEB_DEMO_H_
/*---------------------------------------------------------------------------*/
#include "dev/leds.h"
#include "sys/process.h"
/*---------------------------------------------------------------------------*/
#include "mqtt-client.h"
#include "net-uart.h"
/*---------------------------------------------------------------------------*/
#include <stdint.h>
/*---------------------------------------------------------------------------*/
#ifdef CC26XX_WEB_DEMO_CONF_MQTT_CLIENT
#define CC26XX_WEB_DEMO_MQTT_CLIENT CC26XX_WEB_DEMO_CONF_MQTT_CLIENT
#ifdef WEB_DEMO_CONF_MQTT_CLIENT
#define WEB_DEMO_MQTT_CLIENT WEB_DEMO_CONF_MQTT_CLIENT
#else
#define CC26XX_WEB_DEMO_MQTT_CLIENT 1
#define WEB_DEMO_MQTT_CLIENT 1
#endif
#ifdef CC26XX_WEB_DEMO_CONF_6LBR_CLIENT
#define CC26XX_WEB_DEMO_6LBR_CLIENT CC26XX_WEB_DEMO_CONF_6LBR_CLIENT
#ifdef WEB_DEMO_CONF_6LBR_CLIENT
#define WEB_DEMO_6LBR_CLIENT WEB_DEMO_CONF_6LBR_CLIENT
#else
#define CC26XX_WEB_DEMO_6LBR_CLIENT 1
#define WEB_DEMO_6LBR_CLIENT 1
#endif
#ifdef CC26XX_WEB_DEMO_CONF_COAP_SERVER
#define CC26XX_WEB_DEMO_COAP_SERVER CC26XX_WEB_DEMO_CONF_COAP_SERVER
#ifdef WEB_DEMO_CONF_COAP_SERVER
#define WEB_DEMO_COAP_SERVER WEB_DEMO_CONF_COAP_SERVER
#else
#define CC26XX_WEB_DEMO_COAP_SERVER 1
#define WEB_DEMO_COAP_SERVER 1
#endif
#ifdef CC26XX_WEB_DEMO_CONF_NET_UART
#define CC26XX_WEB_DEMO_NET_UART CC26XX_WEB_DEMO_CONF_NET_UART
#ifdef WEB_DEMO_CONF_NET_UART
#define WEB_DEMO_NET_UART WEB_DEMO_CONF_NET_UART
#else
#define CC26XX_WEB_DEMO_NET_UART 1
#define WEB_DEMO_NET_UART 1
#endif
#ifdef CC26XX_WEB_DEMO_CONF_ADC_DEMO
#define CC26XX_WEB_DEMO_ADC_DEMO CC26XX_WEB_DEMO_CONF_ADC_DEMO
#ifdef WEB_DEMO_CONF_ADC_DEMO
#define WEB_DEMO_ADC_DEMO WEB_DEMO_CONF_ADC_DEMO
#else
#define CC26XX_WEB_DEMO_ADC_DEMO 0
#define WEB_DEMO_ADC_DEMO 0
#endif
/*---------------------------------------------------------------------------*/
/* Active probing of RSSI from our preferred parent */
#if (CC26XX_WEB_DEMO_COAP_SERVER || CC26XX_WEB_DEMO_MQTT_CLIENT)
#define CC26XX_WEB_DEMO_READ_PARENT_RSSI 1
#if (WEB_DEMO_COAP_SERVER || WEB_DEMO_MQTT_CLIENT)
#define WEB_DEMO_READ_PARENT_RSSI 1
#else
#define CC26XX_WEB_DEMO_READ_PARENT_RSSI 0
#define WEB_DEMO_READ_PARENT_RSSI 0
#endif
#define CC26XX_WEB_DEMO_RSSI_MEASURE_INTERVAL_MAX 86400 /* secs: 1 day */
#define CC26XX_WEB_DEMO_RSSI_MEASURE_INTERVAL_MIN 5 /* secs */
#define WEB_DEMO_RSSI_MEASURE_INTERVAL_MAX 86400 /* secs: 1 day */
#define WEB_DEMO_RSSI_MEASURE_INTERVAL_MIN 5 /* secs */
/*---------------------------------------------------------------------------*/
/* User configuration */
/* Take a sensor reading on button press */
#define CC26XX_WEB_DEMO_SENSOR_READING_TRIGGER BUTTON_HAL_ID_KEY_LEFT
#define WEB_DEMO_SENSOR_READING_TRIGGER BUTTON_HAL_ID_KEY_LEFT
/* Payload length of ICMPv6 echo requests used to measure RSSI with def rt */
#define CC26XX_WEB_DEMO_ECHO_REQ_PAYLOAD_LEN 20
#define WEB_DEMO_ECHO_REQ_PAYLOAD_LEN 20
#if BOARD_SENSORTAG
/* Force an MQTT publish on sensor event */
#define CC26XX_WEB_DEMO_MQTT_PUBLISH_TRIGGER BUTTON_HAL_ID_REED_RELAY
#define WEB_DEMO_MQTT_PUBLISH_TRIGGER BUTTON_HAL_ID_REED_RELAY
#elif BOARD_LAUNCHPAD
#define CC26XX_WEB_DEMO_MQTT_PUBLISH_TRIGGER BUTTON_HAL_ID_KEY_LEFT
#define WEB_DEMO_MQTT_PUBLISH_TRIGGER BUTTON_HAL_ID_KEY_LEFT
#else
#define CC26XX_WEB_DEMO_MQTT_PUBLISH_TRIGGER BUTTON_HAL_ID_KEY_DOWN
#define WEB_DEMO_MQTT_PUBLISH_TRIGGER BUTTON_HAL_ID_KEY_DOWN
#endif
#define CC26XX_WEB_DEMO_STATUS_LED LEDS_GREEN
#define WEB_DEMO_STATUS_LED LEDS_GREEN
/*---------------------------------------------------------------------------*/
/* A timeout used when waiting to connect to a network */
#define CC26XX_WEB_DEMO_NET_CONNECT_PERIODIC (CLOCK_SECOND >> 3)
#define WEB_DEMO_NET_CONNECT_PERIODIC (CLOCK_SECOND >> 3)
/*---------------------------------------------------------------------------*/
/* Default configuration values */
#define CC26XX_WEB_DEMO_DEFAULT_ORG_ID "quickstart"
#if CPU_FAMILY_CC13XX
#define CC26XX_WEB_DEMO_DEFAULT_TYPE_ID "cc13xx"
#else
#define CC26XX_WEB_DEMO_DEFAULT_TYPE_ID "cc26xx"
#define WEB_DEMO_DEFAULT_ORG_ID "quickstart"
#if defined(DEVICE_LINE_CC13XX)
#define WEB_DEMO_DEFAULT_TYPE_ID "cc13xx"
#elif defined(DEVICE_LINE_CC26XX)
#define WEB_DEMO_DEFAULT_TYPE_ID "cc26xx"
#endif
#define CC26XX_WEB_DEMO_DEFAULT_EVENT_TYPE_ID "status"
#define CC26XX_WEB_DEMO_DEFAULT_SUBSCRIBE_CMD_TYPE "+"
#define CC26XX_WEB_DEMO_DEFAULT_BROKER_PORT 1883
#define CC26XX_WEB_DEMO_DEFAULT_PUBLISH_INTERVAL (30 * CLOCK_SECOND)
#define CC26XX_WEB_DEMO_DEFAULT_KEEP_ALIVE_TIMER 60
#define CC26XX_WEB_DEMO_DEFAULT_RSSI_MEAS_INTERVAL (CLOCK_SECOND * 30)
#define WEB_DEMO_DEFAULT_EVENT_TYPE_ID "status"
#define WEB_DEMO_DEFAULT_SUBSCRIBE_CMD_TYPE "+"
#define WEB_DEMO_DEFAULT_BROKER_PORT 1883
#define WEB_DEMO_DEFAULT_PUBLISH_INTERVAL (30 * CLOCK_SECOND)
#define WEB_DEMO_DEFAULT_KEEP_ALIVE_TIMER 60
#define WEB_DEMO_DEFAULT_RSSI_MEAS_INTERVAL (CLOCK_SECOND * 30)
/*---------------------------------------------------------------------------*/
/*
* You normally won't have to change anything from here onwards unless you are
@ -137,40 +138,40 @@
*/
/*---------------------------------------------------------------------------*/
/* Sensor types */
#define CC26XX_WEB_DEMO_SENSOR_BATMON_TEMP 0
#define CC26XX_WEB_DEMO_SENSOR_BATMON_VOLT 1
#define CC26XX_WEB_DEMO_SENSOR_BMP_PRES 2
#define CC26XX_WEB_DEMO_SENSOR_BMP_TEMP 3
#define CC26XX_WEB_DEMO_SENSOR_TMP_AMBIENT 4
#define CC26XX_WEB_DEMO_SENSOR_TMP_OBJECT 5
#define CC26XX_WEB_DEMO_SENSOR_HDC_TEMP 6
#define CC26XX_WEB_DEMO_SENSOR_HDC_HUMIDITY 7
#define CC26XX_WEB_DEMO_SENSOR_OPT_LIGHT 8
#define CC26XX_WEB_DEMO_SENSOR_MPU_ACC_X 9
#define CC26XX_WEB_DEMO_SENSOR_MPU_ACC_Y 10
#define CC26XX_WEB_DEMO_SENSOR_MPU_ACC_Z 11
#define CC26XX_WEB_DEMO_SENSOR_MPU_GYRO_X 12
#define CC26XX_WEB_DEMO_SENSOR_MPU_GYRO_Y 13
#define CC26XX_WEB_DEMO_SENSOR_MPU_GYRO_Z 14
#define CC26XX_WEB_DEMO_SENSOR_ADC_DIO23 15
#define WEB_DEMO_SENSOR_BATMON_TEMP 0
#define WEB_DEMO_SENSOR_BATMON_VOLT 1
#define WEB_DEMO_SENSOR_BMP_PRES 2
#define WEB_DEMO_SENSOR_BMP_TEMP 3
#define WEB_DEMO_SENSOR_TMP_AMBIENT 4
#define WEB_DEMO_SENSOR_TMP_OBJECT 5
#define WEB_DEMO_SENSOR_HDC_TEMP 6
#define WEB_DEMO_SENSOR_HDC_HUMIDITY 7
#define WEB_DEMO_SENSOR_OPT_LIGHT 8
#define WEB_DEMO_SENSOR_MPU_ACC_X 9
#define WEB_DEMO_SENSOR_MPU_ACC_Y 10
#define WEB_DEMO_SENSOR_MPU_ACC_Z 11
#define WEB_DEMO_SENSOR_MPU_GYRO_X 12
#define WEB_DEMO_SENSOR_MPU_GYRO_Y 13
#define WEB_DEMO_SENSOR_MPU_GYRO_Z 14
#define WEB_DEMO_SENSOR_ADC_DIO23 15
/*---------------------------------------------------------------------------*/
extern process_event_t cc26xx_web_demo_publish_event;
extern process_event_t cc26xx_web_demo_config_loaded_event;
extern process_event_t cc26xx_web_demo_load_config_defaults;
extern process_event_t web_demo_publish_event;
extern process_event_t web_demo_config_loaded_event;
extern process_event_t web_demo_load_config_defaults;
/*---------------------------------------------------------------------------*/
#define CC26XX_WEB_DEMO_UNIT_TEMP "C"
#define CC26XX_WEB_DEMO_UNIT_VOLT "mV"
#define CC26XX_WEB_DEMO_UNIT_PRES "hPa"
#define CC26XX_WEB_DEMO_UNIT_HUMIDITY "%RH"
#define CC26XX_WEB_DEMO_UNIT_LIGHT "lux"
#define CC26XX_WEB_DEMO_UNIT_ACC "G"
#define CC26XX_WEB_DEMO_UNIT_GYRO "deg per sec"
#define WEB_DEMO_UNIT_TEMP "C"
#define WEB_DEMO_UNIT_VOLT "mV"
#define WEB_DEMO_UNIT_PRES "hPa"
#define WEB_DEMO_UNIT_HUMIDITY "%RH"
#define WEB_DEMO_UNIT_LIGHT "lux"
#define WEB_DEMO_UNIT_ACC "G"
#define WEB_DEMO_UNIT_GYRO "deg per sec"
/*---------------------------------------------------------------------------*/
/* A data type for sensor readings, internally stored in a linked list */
#define CC26XX_WEB_DEMO_CONVERTED_LEN 12
#define WEB_DEMO_CONVERTED_LEN 12
typedef struct cc26xx_web_demo_sensor_reading {
struct cc26xx_web_demo_sensor_reading *next;
typedef struct web_demo_sensor_reading {
struct web_demo_sensor_reading *next;
int raw;
int last;
const char *descr;
@ -180,33 +181,33 @@ typedef struct cc26xx_web_demo_sensor_reading {
uint8_t type;
uint8_t publish;
uint8_t changed;
char converted[CC26XX_WEB_DEMO_CONVERTED_LEN];
} cc26xx_web_demo_sensor_reading_t;
char converted[WEB_DEMO_CONVERTED_LEN];
} web_demo_sensor_reading_t;
/*---------------------------------------------------------------------------*/
/* Global configuration */
typedef struct cc26xx_web_demo_config_s {
typedef struct web_demo_config_s {
uint32_t magic;
int len;
uint32_t sensors_bitmap;
int def_rt_ping_interval;
mqtt_client_config_t mqtt_config;
net_uart_config_t net_uart;
} cc26xx_web_demo_config_t;
} web_demo_config_t;
extern cc26xx_web_demo_config_t cc26xx_web_demo_config;
extern web_demo_config_t web_demo_config;
/*---------------------------------------------------------------------------*/
/**
* \brief Performs a lookup for a reading of a specific type of sensor
* \param sens_type CC26XX_WEB_DEMO_SENSOR_BATMON_TEMP...
* \param sens_type WEB_DEMO_SENSOR_BATMON_TEMP...
* \return A pointer to the reading data structure or NULL
*/
const cc26xx_web_demo_sensor_reading_t *cc26xx_web_demo_sensor_lookup(int sens_type);
const web_demo_sensor_reading_t *web_demo_sensor_lookup(int sens_type);
/**
* \brief Returns the first available sensor reading
* \return A pointer to the reading data structure or NULL
*/
const cc26xx_web_demo_sensor_reading_t *cc26xx_web_demo_sensor_first(void);
const web_demo_sensor_reading_t *web_demo_sensor_first(void);
/**
* \brief Print an IPv6 address into a buffer
@ -218,15 +219,15 @@ const cc26xx_web_demo_sensor_reading_t *cc26xx_web_demo_sensor_first(void);
*
* It is the caller's responsibility to allocate enough space for buf
*/
int cc26xx_web_demo_ipaddr_sprintf(char *buf, uint8_t buf_len,
int web_demo_ipaddr_sprintf(char *buf, uint8_t buf_len,
const uip_ipaddr_t *addr);
/**
* \brief Resets the example to a default configuration
*/
void cc26xx_web_demo_restore_defaults(void);
void web_demo_restore_defaults(void);
/*---------------------------------------------------------------------------*/
#endif /* CC26XX_WEB_DEMO_H_ */
#endif /* WEB_DEMO_H_ */
/*---------------------------------------------------------------------------*/
/**
* @}