Modify cc26xx examples to play nicely with the CC13xx addition
This commit is contained in:
parent
3d19b0036e
commit
72b586cb7d
9 changed files with 62 additions and 36 deletions
|
@ -6,8 +6,9 @@ boards. More specifically, the example demonstrates:
|
|||
* How to take sensor readings
|
||||
* How to use buttons and the reed relay (triggered by holding a magnet near S3
|
||||
on the SensorTag).
|
||||
* How to send out BLE advertisements. The device will periodically send out BLE
|
||||
beacons with the platform name as payload. Those beacons/BLE ADV packets can
|
||||
be captured with any BLE capable device. Two such applications for iOS are the
|
||||
TI Multitool and the TI Sensortag app. They can be found in the Apple App
|
||||
Store. If you have a BLE-capable Mac, you can also use LightBlue for OS X.
|
||||
* How to send out BLE advertisements, if the chip has BLE capability. The
|
||||
device will periodically send out BLE beacons with the platform name as
|
||||
payload. Those beacons/BLE ADV packets can be captured with any BLE-capable
|
||||
device. Two such applications for iOS are the TI Multitool and the TI
|
||||
Sensortag app. They can be found in the Apple App Store. If you have a
|
||||
BLE-capable Mac, you can also use LightBlue for OS X.
|
||||
|
|
|
@ -88,13 +88,12 @@
|
|||
#include "sys/etimer.h"
|
||||
#include "sys/ctimer.h"
|
||||
#include "dev/leds.h"
|
||||
#include "dev/serial-line.h"
|
||||
#include "dev/watchdog.h"
|
||||
#include "random.h"
|
||||
#include "button-sensor.h"
|
||||
#include "batmon-sensor.h"
|
||||
#include "board-peripherals.h"
|
||||
#include "cc26xx-rf.h"
|
||||
#include "rf-core/rf-ble.h"
|
||||
|
||||
#include "ti-lib.h"
|
||||
|
||||
|
@ -104,7 +103,6 @@
|
|||
#define CC26XX_DEMO_LOOP_INTERVAL (CLOCK_SECOND * 20)
|
||||
#define CC26XX_DEMO_LEDS_PERIODIC LEDS_YELLOW
|
||||
#define CC26XX_DEMO_LEDS_BUTTON LEDS_RED
|
||||
#define CC26XX_DEMO_LEDS_SERIAL_IN LEDS_ORANGE
|
||||
#define CC26XX_DEMO_LEDS_REBOOT LEDS_ALL
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define CC26XX_DEMO_SENSOR_NONE (void *)0xFFFFFFFF
|
||||
|
@ -370,8 +368,8 @@ PROCESS_THREAD(cc26xx_demo_process, ev, data)
|
|||
init_sensors();
|
||||
|
||||
/* Init the BLE advertisement daemon */
|
||||
cc26xx_rf_ble_beacond_config(0, BOARD_STRING);
|
||||
cc26xx_rf_ble_beacond_start();
|
||||
rf_ble_beacond_config(0, BOARD_STRING);
|
||||
rf_ble_beacond_start();
|
||||
|
||||
etimer_set(&et, CC26XX_DEMO_LOOP_INTERVAL);
|
||||
get_sync_sensor_readings();
|
||||
|
|
|
@ -10,12 +10,11 @@ demonstrate the CC26xx capability. The applications are:
|
|||
* A web server which can be used to display sensor readings but also to
|
||||
configure MQTT functionality
|
||||
|
||||
The example has been configured to run for both CC26xx-based boards: i) The
|
||||
SensorTag 2.0 and ii) The Srf06EB with a CC26xx EM mounted on it.
|
||||
The example has been configured to run for all CC26xx-based boards: i) The
|
||||
SensorTag 2.0 and ii) The Srf06EB with a CC26xx or CC13xx EM mounted on it.
|
||||
|
||||
To build the example for the Srf, simply run `make`. To build for the tag,
|
||||
run `make BOARD=sensortag`. Do not forget to `make clean` when switching
|
||||
between the two platforms.
|
||||
To change between target boards, follow the instructions in the platform's
|
||||
REDME file. Do not forget to `make clean` when switching between the boards.
|
||||
|
||||
You can disable some of those individual components by changing the respective
|
||||
defines in `project-conf.h`. For instance, to disable the CoAP functionality,
|
||||
|
|
|
@ -91,7 +91,7 @@
|
|||
/* Force an MQTT publish on sensor event */
|
||||
#define CC26XX_WEB_DEMO_MQTT_PUBLISH_TRIGGER &reed_relay_sensor
|
||||
#else
|
||||
#define CC26XX_WEB_DEMO_MQTT_PUBLISH_TRIGGER &button_right_sensor
|
||||
#define CC26XX_WEB_DEMO_MQTT_PUBLISH_TRIGGER &button_down_sensor
|
||||
#endif
|
||||
|
||||
#define CC26XX_WEB_DEMO_STATUS_LED LEDS_GREEN
|
||||
|
@ -101,7 +101,11 @@
|
|||
/*---------------------------------------------------------------------------*/
|
||||
/* 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"
|
||||
#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
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include "contiki-net.h"
|
||||
#include "rest-engine.h"
|
||||
#include "board-peripherals.h"
|
||||
#include "dev/cc26xx-rf.h"
|
||||
#include "rf-core/rf-ble.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -56,7 +56,7 @@ extern resource_t res_device_hw;
|
|||
extern resource_t res_device_uptime;
|
||||
extern resource_t res_device_cfg_reset;
|
||||
|
||||
#if CC26XX_RF_BLE_SUPPORT
|
||||
#if RF_BLE_ENABLED
|
||||
extern resource_t res_ble_advd;
|
||||
#endif
|
||||
|
||||
|
@ -138,7 +138,7 @@ PROCESS_THREAD(coap_server_process, ev, data)
|
|||
rest_activate_resource(&res_device_uptime, "dev/uptime");
|
||||
rest_activate_resource(&res_device_cfg_reset, "dev/cfg_reset");
|
||||
|
||||
#if CC26XX_RF_BLE_SUPPORT
|
||||
#if RF_BLE_ENABLED
|
||||
rest_activate_resource(&res_ble_advd, "dev/ble_advd");
|
||||
#endif
|
||||
|
||||
|
|
|
@ -32,11 +32,9 @@
|
|||
#define PROJECT_CONF_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Change to match your configuration */
|
||||
#define NETSTACK_CONF_RDC contikimac_driver
|
||||
#define IEEE802154_CONF_PANID 0xABCD
|
||||
#define CC26XX_RF_CONF_CHANNEL 25
|
||||
#define CC26XX_MODEL_CONF_CPU_VARIANT 2650 /* CC2650 */
|
||||
#define CC26XX_RF_CONF_BLE_SUPPORT 1 /* Only available with CC2650 */
|
||||
#define RF_CORE_CONF_CHANNEL 25
|
||||
#define RF_BLE_CONF_ENABLED 1
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Enable/Disable Components of this Demo */
|
||||
#define CC26XX_WEB_DEMO_CONF_MQTT_CLIENT 1
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include "contiki.h"
|
||||
#include "rest-engine.h"
|
||||
#include "er-coap.h"
|
||||
#include "dev/cc26xx-rf.h"
|
||||
#include "rf-core/rf-ble.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -64,7 +64,7 @@ res_ble_post_put_handler(void *request, void *response, uint8_t *buffer,
|
|||
|
||||
if(len > 0 && len < BLE_NAME_BUF_LEN) {
|
||||
memcpy(name, text, len);
|
||||
cc26xx_rf_ble_beacond_config(0, name);
|
||||
rf_ble_beacond_config(0, name);
|
||||
success = 1;
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ res_ble_post_put_handler(void *request, void *response, uint8_t *buffer,
|
|||
rv = atoi(text);
|
||||
|
||||
if(rv > 0) {
|
||||
cc26xx_rf_ble_beacond_config((clock_time_t)(rv * CLOCK_SECOND), NULL);
|
||||
rf_ble_beacond_config((clock_time_t)(rv * CLOCK_SECOND), NULL);
|
||||
success = 1;
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ res_ble_post_put_handler(void *request, void *response, uint8_t *buffer,
|
|||
|
||||
if(len) {
|
||||
if(strncmp(text, "on", len) == 0) {
|
||||
if(cc26xx_rf_ble_beacond_start()) {
|
||||
if(rf_ble_beacond_start()) {
|
||||
success = 1;
|
||||
} else {
|
||||
REST.set_response_status(response, REST.status.FORBIDDEN);
|
||||
|
@ -90,7 +90,7 @@ res_ble_post_put_handler(void *request, void *response, uint8_t *buffer,
|
|||
return;
|
||||
}
|
||||
} else if(strncmp(text, "off", len) == 0) {
|
||||
cc26xx_rf_ble_beacond_stop();
|
||||
rf_ble_beacond_stop();
|
||||
success = 1;
|
||||
} else {
|
||||
success = 0;
|
||||
|
|
|
@ -40,37 +40,65 @@
|
|||
#include "rest-engine.h"
|
||||
#include "er-coap.h"
|
||||
#include "sys/clock.h"
|
||||
#include "cc26xx-model.h"
|
||||
#include "coap-server.h"
|
||||
#include "cc26xx-web-demo.h"
|
||||
|
||||
#include "ti-lib.h"
|
||||
|
||||
#include <string.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static uint16_t
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
res_get_handler_hw(void *request, void *response, uint8_t *buffer,
|
||||
uint16_t preferred_size, int32_t *offset)
|
||||
{
|
||||
unsigned int accept = -1;
|
||||
uint16_t chip = detect_chip();
|
||||
|
||||
REST.get_header_accept(request, &accept);
|
||||
|
||||
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
|
||||
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
|
||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%s on CC%u", BOARD_STRING,
|
||||
CC26XX_MODEL_CPU_VARIANT);
|
||||
chip);
|
||||
|
||||
REST.set_response_payload(response, (uint8_t *)buffer, strlen((char *)buffer));
|
||||
} else if(accept == REST.type.APPLICATION_JSON) {
|
||||
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
|
||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{\"HW Ver\":\"%s on CC%u\"}",
|
||||
BOARD_STRING, CC26XX_MODEL_CPU_VARIANT);
|
||||
BOARD_STRING, chip);
|
||||
|
||||
REST.set_response_payload(response, buffer, strlen((char *)buffer));
|
||||
} else if(accept == REST.type.APPLICATION_XML) {
|
||||
REST.set_header_content_type(response, REST.type.APPLICATION_XML);
|
||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE,
|
||||
"<hw-ver val=\"%s on CC%u\"/>", BOARD_STRING,
|
||||
CC26XX_MODEL_CPU_VARIANT);
|
||||
chip);
|
||||
|
||||
REST.set_response_payload(response, buffer, strlen((char *)buffer));
|
||||
} else {
|
||||
|
|
|
@ -35,11 +35,9 @@
|
|||
#define BUTTON_SENSOR_CONF_ENABLE_SHUTDOWN 0
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Change to match your configuration */
|
||||
#define NETSTACK_CONF_RDC contikimac_driver
|
||||
#define IEEE802154_CONF_PANID 0xABCD
|
||||
#define CC26XX_RF_CONF_CHANNEL 25
|
||||
#define CC26XX_MODEL_CONF_CPU_VARIANT 2650 /* CC2650 */
|
||||
#define CC26XX_RF_CONF_BLE_SUPPORT 1 /* Only available with CC2650 */
|
||||
#define RF_CORE_CONF_CHANNEL 25
|
||||
#define RF_BLE_CONF_ENABLED 1
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* PROJECT_CONF_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
Loading…
Reference in a new issue