Removed obsolete radio-sensor API
This commit is contained in:
parent
91b8ee860e
commit
358385b450
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
CONTIKI_TARGET_SOURCEFILES += contiki-sky-platform.c \
|
CONTIKI_TARGET_SOURCEFILES += contiki-sky-platform.c \
|
||||||
sht11.c sht11-sensor.c light-sensor.c battery-sensor.c \
|
sht11.c sht11-sensor.c light-sensor.c battery-sensor.c \
|
||||||
button-sensor.c radio-sensor.c
|
button-sensor.c
|
||||||
|
|
||||||
include $(CONTIKI)/arch/platform/sky/Makefile.common
|
include $(CONTIKI)/arch/platform/sky/Makefile.common
|
||||||
|
|
||||||
|
@ -1,75 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2005, Swedish Institute of Computer Science
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* This file is part of the Contiki operating system.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "lib/sensors.h"
|
|
||||||
#include "cc2420.h"
|
|
||||||
#include "dev/radio-sensor.h"
|
|
||||||
|
|
||||||
const struct sensors_sensor radio_sensor;
|
|
||||||
static int active;
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static int
|
|
||||||
value(int type)
|
|
||||||
{
|
|
||||||
switch(type) {
|
|
||||||
case RADIO_SENSOR_LAST_PACKET:
|
|
||||||
return cc2420_last_correlation;
|
|
||||||
case RADIO_SENSOR_LAST_VALUE:
|
|
||||||
default:
|
|
||||||
return cc2420_last_rssi;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static int
|
|
||||||
configure(int type, int c)
|
|
||||||
{
|
|
||||||
if(type == SENSORS_ACTIVE) {
|
|
||||||
active = c;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static int
|
|
||||||
status(int type)
|
|
||||||
{
|
|
||||||
switch(type) {
|
|
||||||
case SENSORS_ACTIVE:
|
|
||||||
case SENSORS_READY:
|
|
||||||
return active;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
SENSORS_SENSOR(radio_sensor, RADIO_SENSOR,
|
|
||||||
value, configure, status);
|
|
@ -91,7 +91,6 @@ extern resource_t res_temperature;
|
|||||||
extern resource_t res_battery;
|
extern resource_t res_battery;
|
||||||
#endif
|
#endif
|
||||||
#if PLATFORM_HAS_RADIO
|
#if PLATFORM_HAS_RADIO
|
||||||
#include "dev/radio-sensor.h"
|
|
||||||
extern resource_t res_radio;
|
extern resource_t res_radio;
|
||||||
#endif
|
#endif
|
||||||
#if PLATFORM_HAS_SHT11
|
#if PLATFORM_HAS_SHT11
|
||||||
@ -158,7 +157,6 @@ PROCESS_THREAD(er_example_server, ev, data)
|
|||||||
/*
|
/*
|
||||||
#if PLATFORM_HAS_RADIO
|
#if PLATFORM_HAS_RADIO
|
||||||
rest_activate_resource(&res_radio, "sensors/radio");
|
rest_activate_resource(&res_radio, "sensors/radio");
|
||||||
SENSORS_ACTIVATE(radio_sensor);
|
|
||||||
#endif
|
#endif
|
||||||
#if PLATFORM_HAS_SHT11
|
#if PLATFORM_HAS_SHT11
|
||||||
rest_activate_resource(&res_sht11, "sensors/sht11");
|
rest_activate_resource(&res_sht11, "sensors/sht11");
|
||||||
|
@ -42,13 +42,13 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "rest-engine.h"
|
#include "rest-engine.h"
|
||||||
#include "dev/radio-sensor.h"
|
#include "net/netstack.h"
|
||||||
|
|
||||||
static void res_get_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
|
static void res_get_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
|
||||||
|
|
||||||
/* A simple getter example. Returns the reading of the rssi/lqi from radio sensor */
|
/* A simple getter example. Returns the reading of the rssi/lqi from radio sensor */
|
||||||
RESOURCE(res_radio,
|
RESOURCE(res_radio,
|
||||||
"title=\"RADIO: ?p=lqi|rssi\";rt=\"RadioSensor\"",
|
"title=\"RADIO: ?p=rssi\";rt=\"RadioSensor\"",
|
||||||
res_get_handler,
|
res_get_handler,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
@ -59,36 +59,33 @@ res_get_handler(void *request, void *response, uint8_t *buffer, uint16_t preferr
|
|||||||
{
|
{
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
const char *p = NULL;
|
const char *p = NULL;
|
||||||
uint8_t param = 0;
|
radio_value_t value;
|
||||||
int success = 1;
|
int8_t rssi = 0;
|
||||||
|
int success = 0;
|
||||||
unsigned int accept = -1;
|
unsigned int accept = -1;
|
||||||
|
|
||||||
REST.get_header_accept(request, &accept);
|
REST.get_header_accept(request, &accept);
|
||||||
|
|
||||||
if((len = REST.get_query_variable(request, "p", &p))) {
|
if((len = REST.get_query_variable(request, "p", &p))) {
|
||||||
if(strncmp(p, "lqi", len) == 0) {
|
if(strncmp(p, "rssi", len) == 0) {
|
||||||
param = RADIO_SENSOR_LAST_VALUE;
|
if(NETSTACK_RADIO.get_value(RADIO_PARAM_RSSI, &value) ==
|
||||||
} else if(strncmp(p, "rssi", len) == 0) {
|
RADIO_RESULT_OK) {
|
||||||
param = RADIO_SENSOR_LAST_PACKET;
|
success = 1;
|
||||||
} else {
|
rssi = (int8_t)value;
|
||||||
success = 0;
|
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
success = 0;
|
}
|
||||||
} if(success) {
|
|
||||||
|
if(success) {
|
||||||
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
|
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
|
||||||
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
|
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
|
||||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%d", radio_sensor.value(param));
|
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%d", rssi);
|
||||||
|
|
||||||
REST.set_response_payload(response, (uint8_t *)buffer, strlen((char *)buffer));
|
REST.set_response_payload(response, (uint8_t *)buffer, strlen((char *)buffer));
|
||||||
} else if(accept == REST.type.APPLICATION_JSON) {
|
} else if(accept == REST.type.APPLICATION_JSON) {
|
||||||
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
|
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
|
||||||
|
|
||||||
if(param == RADIO_SENSOR_LAST_VALUE) {
|
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{'rssi':%d}", rssi);
|
||||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{'lqi':%d}", radio_sensor.value(param));
|
|
||||||
} else if(param == RADIO_SENSOR_LAST_PACKET) {
|
|
||||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{'rssi':%d}", radio_sensor.value(param));
|
|
||||||
}
|
|
||||||
REST.set_response_payload(response, buffer, strlen((char *)buffer));
|
REST.set_response_payload(response, buffer, strlen((char *)buffer));
|
||||||
} else {
|
} else {
|
||||||
REST.set_response_status(response, REST.status.NOT_ACCEPTABLE);
|
REST.set_response_status(response, REST.status.NOT_ACCEPTABLE);
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2005, Swedish Institute of Computer Science
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* This file is part of the Contiki operating system.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#ifndef RADIO_SENSOR_H_
|
|
||||||
#define RADIO_SENSOR_H_
|
|
||||||
|
|
||||||
#include "lib/sensors.h"
|
|
||||||
|
|
||||||
extern const struct sensors_sensor radio_sensor;
|
|
||||||
|
|
||||||
#define RADIO_SENSOR_LAST_VALUE 0
|
|
||||||
#define RADIO_SENSOR_LAST_PACKET 1
|
|
||||||
|
|
||||||
#define RADIO_SENSOR "Radio"
|
|
||||||
|
|
||||||
extern unsigned int radio_sensor_signal;
|
|
||||||
|
|
||||||
#endif /* RADIO_SENSOR_H_ */
|
|
Loading…
Reference in New Issue
Block a user