Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
e3da-public
contiki-ng
Commits
358385b4
Commit
358385b4
authored
Oct 13, 2017
by
Niclas Finne
Browse files
Removed obsolete radio-sensor API
parent
91b8ee86
Changes
5
Hide whitespace changes
Inline
Side-by-side
arch/platform/sky/Makefile.sky
View file @
358385b4
...
...
@@ -2,7 +2,7 @@
CONTIKI_TARGET_SOURCEFILES
+=
contiki-sky-platform.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
...
...
arch/platform/sky/dev/radio-sensor.c
deleted
100644 → 0
View file @
91b8ee86
/*
* 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
);
examples/ipv6/coap-example/coap-example-server.c
View file @
358385b4
...
...
@@ -91,7 +91,6 @@ extern resource_t res_temperature;
extern resource_t res_battery;
#endif
#if PLATFORM_HAS_RADIO
#include "dev/radio-sensor.h"
extern resource_t res_radio;
#endif
#if PLATFORM_HAS_SHT11
...
...
@@ -157,8 +156,7 @@ PROCESS_THREAD(er_example_server, ev, data)
#endif
/*
#if PLATFORM_HAS_RADIO
rest_activate_resource(&res_radio, "sensors/radio");
SENSORS_ACTIVATE(radio_sensor);
rest_activate_resource(&res_radio, "sensors/radio");
#endif
#if PLATFORM_HAS_SHT11
rest_activate_resource(&res_sht11, "sensors/sht11");
...
...
examples/ipv6/coap-example/resources/res-radio.c
View file @
358385b4
...
...
@@ -42,13 +42,13 @@
#include <string.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
);
/* A simple getter example. Returns the reading of the rssi/lqi from radio sensor */
RESOURCE
(
res_radio
,
"title=
\"
RADIO: ?p=
lqi|
rssi
\"
;rt=
\"
RadioSensor
\"
"
,
"title=
\"
RADIO: ?p=rssi
\"
;rt=
\"
RadioSensor
\"
"
,
res_get_handler
,
NULL
,
NULL
,
...
...
@@ -59,36 +59,33 @@ res_get_handler(void *request, void *response, uint8_t *buffer, uint16_t preferr
{
size_t
len
=
0
;
const
char
*
p
=
NULL
;
uint8_t
param
=
0
;
int
succe
ss
=
1
;
radio_value_t
value
;
int
8_t
r
ss
i
=
0
;
int
success
=
0
;
unsigned
int
accept
=
-
1
;
REST
.
get_header_accept
(
request
,
&
accept
);
if
((
len
=
REST
.
get_query_variable
(
request
,
"p"
,
&
p
)))
{
if
(
strncmp
(
p
,
"
lq
i"
,
len
)
==
0
)
{
param
=
RADIO_SENSOR_LAST_VALUE
;
}
else
if
(
strncmp
(
p
,
"rssi"
,
len
)
==
0
)
{
param
=
RADIO_SENSOR_LAST_PACKET
;
}
else
{
success
=
0
;
if
(
strncmp
(
p
,
"
rss
i"
,
len
)
==
0
)
{
if
(
NETSTACK_RADIO
.
get_value
(
RADIO_PARAM_RSSI
,
&
value
)
==
RADIO_RESULT_OK
)
{
success
=
1
;
rssi
=
(
int8_t
)
value
;
}
}
}
else
{
success
=
0
;
}
if
(
success
)
{
}
if
(
success
)
{
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
,
"%d"
,
r
adio_sensor
.
value
(
param
)
);
snprintf
((
char
*
)
buffer
,
REST_MAX_CHUNK_SIZE
,
"%d"
,
r
ssi
);
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
);
if
(
param
==
RADIO_SENSOR_LAST_VALUE
)
{
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
));
}
snprintf
((
char
*
)
buffer
,
REST_MAX_CHUNK_SIZE
,
"{'rssi':%d}"
,
rssi
);
REST
.
set_response_payload
(
response
,
buffer
,
strlen
((
char
*
)
buffer
));
}
else
{
REST
.
set_response_status
(
response
,
REST
.
status
.
NOT_ACCEPTABLE
);
...
...
os/dev/radio-sensor.h
deleted
100644 → 0
View file @
91b8ee86
/*
* 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_ */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment