Skip to content

Commit 21f2b42

Browse files
author
Nicolas Tsiftes
committed
Merge branch 'master' of ssh://contiki.git.sourceforge.net/gitroot/contiki/contiki
2 parents 4f6fb98 + 37c407b commit 21f2b42

File tree

17 files changed

+271
-250
lines changed

17 files changed

+271
-250
lines changed

cpu/msp430/f2xxx/uart0.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
#include "dev/uart0.h"
4141
#include "dev/watchdog.h"
4242
#include "lib/ringbuf.h"
43-
#include "dev/leds.h"
4443
#include "isr_compat.h"
4544

4645
static int (*uart0_input_handler)(unsigned char c);
@@ -144,7 +143,6 @@ ISR(USCIAB0RX, uart0_rx_interrupt)
144143
uint8_t c;
145144

146145
ENERGEST_ON(ENERGEST_TYPE_IRQ);
147-
leds_toggle(LEDS_RED);
148146
if(UCA0STAT & UCRXERR) {
149147
c = UCA0RXBUF; /* Clear error flags by forcing a dummy read. */
150148
} else {

examples/er-rest-example/er-example-server.c

Lines changed: 114 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@
5050
#define REST_RES_SEPARATE 1
5151
#define REST_RES_PUSHING 1
5252
#define REST_RES_EVENT 1
53+
#define REST_RES_SUB 1
5354
#define REST_RES_LEDS 1
5455
#define REST_RES_TOGGLE 1
5556
#define REST_RES_LIGHT 0
5657
#define REST_RES_BATTERY 0
58+
#define REST_RES_RADIO 1
5759

5860

5961

@@ -80,6 +82,9 @@
8082
#if defined (PLATFORM_HAS_SHT11)
8183
#include "dev/sht11-sensor.h"
8284
#endif
85+
#if defined (PLATFORM_HAS_RADIO)
86+
#include "dev/radio-sensor.h"
87+
#endif
8388

8489

8590
/* For CoAP-specific example: not required for normal RESTful Web service. */
@@ -475,7 +480,7 @@ pushing_periodic_handler(resource_t *r)
475480

476481
++obs_counter;
477482

478-
PRINTF("TICK %u for /%s\n", periodic_i, r->url);
483+
PRINTF("TICK %u for /%s\n", obs_counter, r->url);
479484

480485
/* Build notification. */
481486
coap_packet_t notification[1]; /* This way the packet can be treated as pointer as usual. */
@@ -529,6 +534,36 @@ event_event_handler(resource_t *r)
529534
}
530535
#endif /* PLATFORM_HAS_BUTTON */
531536

537+
/******************************************************************************/
538+
#if REST_RES_SUB
539+
/*
540+
* Example for a resource that also handles all its sub-resources.
541+
* Use REST.get_url() to multiplex the handling of the request depending on the Uri-Path.
542+
*/
543+
RESOURCE(sub, METHOD_GET | HAS_SUB_RESOURCES, "test/path", "title=\"Sub-resource demo\"");
544+
545+
void
546+
sub_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
547+
{
548+
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
549+
550+
const char *uri_path = NULL;
551+
int len = REST.get_url(request, &uri_path);
552+
int base_len = strlen(resource_sub.url);
553+
554+
if (len==base_len)
555+
{
556+
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "Request any sub-resource of /%s", resource_sub.url);
557+
}
558+
else
559+
{
560+
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, ".%s", uri_path+base_len);
561+
}
562+
563+
REST.set_response_payload(response, buffer, strlen((char *)buffer));
564+
}
565+
#endif
566+
532567
/******************************************************************************/
533568
#if defined (PLATFORM_HAS_LEDS)
534569
/******************************************************************************/
@@ -609,23 +644,23 @@ light_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred
609644
if ((num==0) || (num && accept[0]==REST.type.TEXT_PLAIN))
610645
{
611646
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
612-
snprintf(buffer, REST_MAX_CHUNK_SIZE, "%u;%u", light_photosynthetic, light_solar);
647+
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%u;%u", light_photosynthetic, light_solar);
613648

614-
REST.set_response_payload(response, (uint8_t *)buffer, strlen(buffer));
649+
REST.set_response_payload(response, (uint8_t *)buffer, strlen((char *)buffer));
615650
}
616651
else if (num && (accept[0]==REST.type.APPLICATION_XML))
617652
{
618653
REST.set_header_content_type(response, REST.type.APPLICATION_XML);
619-
snprintf(buffer, REST_MAX_CHUNK_SIZE, "<light photosynthetic=\"%u\" solar=\"%u\"/>", light_photosynthetic, light_solar);
654+
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "<light photosynthetic=\"%u\" solar=\"%u\"/>", light_photosynthetic, light_solar);
620655

621-
REST.set_response_payload(response, buffer, strlen(buffer));
656+
REST.set_response_payload(response, buffer, strlen((char *)buffer));
622657
}
623658
else if (num && (accept[0]==REST.type.APPLICATION_JSON))
624659
{
625660
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
626-
snprintf(buffer, REST_MAX_CHUNK_SIZE, "{'light':{'photosynthetic':%u,'solar':%u}}", light_photosynthetic, light_solar);
661+
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{'light':{'photosynthetic':%u,'solar':%u}}", light_photosynthetic, light_solar);
627662

628-
REST.set_response_payload(response, buffer, strlen(buffer));
663+
REST.set_response_payload(response, buffer, strlen((char *)buffer));
629664
}
630665
else
631666
{
@@ -651,16 +686,16 @@ battery_handler(void* request, void* response, uint8_t *buffer, uint16_t preferr
651686
if ((num==0) || (num && accept[0]==REST.type.TEXT_PLAIN))
652687
{
653688
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
654-
snprintf(buffer, REST_MAX_CHUNK_SIZE, "%d", battery);
689+
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%d", battery);
655690

656-
REST.set_response_payload(response, (uint8_t *)buffer, strlen(buffer));
691+
REST.set_response_payload(response, (uint8_t *)buffer, strlen((char *)buffer));
657692
}
658693
else if (num && (accept[0]==REST.type.APPLICATION_JSON))
659694
{
660695
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
661-
snprintf(buffer, REST_MAX_CHUNK_SIZE, "{'battery':%d}", battery);
696+
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{'battery':%d}", battery);
662697

663-
REST.set_response_payload(response, buffer, strlen(buffer));
698+
REST.set_response_payload(response, buffer, strlen((char *)buffer));
664699
}
665700
else
666701
{
@@ -672,6 +707,67 @@ battery_handler(void* request, void* response, uint8_t *buffer, uint16_t preferr
672707
#endif /* PLATFORM_HAS_BATTERY */
673708

674709

710+
#if defined (PLATFORM_HAS_RADIO) && REST_RES_RADIO
711+
/* A simple getter example. Returns the reading of the rssi/lqi from radio sensor */
712+
RESOURCE(radio, METHOD_GET, "sensor/radio", "title=\"RADIO: ?p=lqi|rssi\";rt=\"RadioSensor\"");
713+
714+
void
715+
radio_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
716+
{
717+
size_t len = 0;
718+
const char *p = NULL;
719+
uint8_t param = 0;
720+
int success = 1;
721+
722+
const uint16_t *accept = NULL;
723+
int num = REST.get_header_accept(request, &accept);
724+
725+
if ((len=REST.get_query_variable(request, "p", &p))) {
726+
PRINTF("p %.*s\n", len, p);
727+
if (strncmp(p, "lqi", len)==0) {
728+
param = RADIO_SENSOR_LAST_VALUE;
729+
} else if(strncmp(p,"rssi", len)==0) {
730+
param = RADIO_SENSOR_LAST_PACKET;
731+
} else {
732+
success = 0;
733+
}
734+
} else {
735+
success = 0;
736+
}
737+
738+
if (success) {
739+
if ((num==0) || (num && accept[0]==REST.type.TEXT_PLAIN))
740+
{
741+
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
742+
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%d", radio_sensor.value(param));
743+
744+
REST.set_response_payload(response, (uint8_t *)buffer, strlen((char *)buffer));
745+
}
746+
else if (num && (accept[0]==REST.type.APPLICATION_JSON))
747+
{
748+
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
749+
750+
if (param == RADIO_SENSOR_LAST_VALUE) {
751+
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{'lqi':%d}", radio_sensor.value(param));
752+
} else if (param == RADIO_SENSOR_LAST_PACKET) {
753+
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{'rssi':%d}", radio_sensor.value(param));
754+
}
755+
756+
REST.set_response_payload(response, buffer, strlen((char *)buffer));
757+
}
758+
else
759+
{
760+
REST.set_response_status(response, REST.status.UNSUPPORTED_MADIA_TYPE);
761+
const char *msg = "Supporting content-types text/plain and application/json";
762+
REST.set_response_payload(response, msg, strlen(msg));
763+
}
764+
} else {
765+
REST.set_response_status(response, REST.status.BAD_REQUEST);
766+
}
767+
}
768+
#endif
769+
770+
675771

676772
PROCESS(rest_server_example, "Erbium Example Server");
677773
AUTOSTART_PROCESSES(&rest_server_example);
@@ -726,6 +822,9 @@ PROCESS_THREAD(rest_server_example, ev, data)
726822
#if defined (PLATFORM_HAS_BUTTON) && (REST_RES_EVENT || (REST_RES_SEPARATE && WITH_COAP > 3))
727823
SENSORS_ACTIVATE(button_sensor);
728824
#endif
825+
#if REST_RES_SUB
826+
rest_activate_resource(&resource_sub);
827+
#endif
729828
#if defined (PLATFORM_HAS_LEDS)
730829
#if REST_RES_LEDS
731830
rest_activate_resource(&resource_leds);
@@ -742,6 +841,10 @@ PROCESS_THREAD(rest_server_example, ev, data)
742841
SENSORS_ACTIVATE(battery_sensor);
743842
rest_activate_resource(&resource_battery);
744843
#endif
844+
#if defined (PLATFORM_HAS_RADIO) && REST_RES_RADIO
845+
SENSORS_ACTIVATE(radio_sensor);
846+
rest_activate_resource(&resource_radio);
847+
#endif
745848

746849
/* Define application-specific events here. */
747850
while(1) {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include <avr/eeprom.h>
22

33
/* Link layer ipv6 address will become fe80::2 */
4-
uint8_t default_mac_address[8] PROGMEM = {0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02};
5-
uint8_t default_server_name[16] PROGMEM = "huginn";
6-
uint8_t default_domain_name[30] PROGMEM = "localhost";
4+
const uint8_t default_mac_address[8] PROGMEM = {0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02};
5+
const uint8_t default_server_name[16] PROGMEM = "huginn";
6+
const uint8_t default_domain_name[30] PROGMEM = "localhost";
77
uint8_t eemem_mac_address[8] EEMEM = {0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02};
88
uint8_t eemem_server_name[16] EEMEM = "huginn";
99
uint8_t eemem_domain_name[30] EEMEM = "localhost";
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include <avr/eeprom.h>
22

33
/* Link layer ipv6 address will become fe80::1 */
4-
uint8_t default_mac_address[8] PROGMEM = {0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
5-
uint8_t default_server_name[16] PROGMEM = "muninn";
6-
uint8_t default_domain_name[30] PROGMEM = "localhost";
4+
const uint8_t default_mac_address[8] PROGMEM = {0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
5+
const uint8_t default_server_name[16] PROGMEM = "muninn";
6+
const uint8_t default_domain_name[30] PROGMEM = "localhost";
77
uint8_t eemem_mac_address[8] EEMEM = {0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
88
uint8_t eemem_server_name[16] EEMEM = "muninn";
99
uint8_t eemem_domain_name[30] EEMEM = "localhost";

platform/avr-atmega128rfa1/apps/raven-webserver/httpd-fs/makefsdata.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include <avr/eeprom.h>
22

33
/* Link layer ipv6 address will become fe80::ff:fe:1 */
4-
uint8_t default_mac_address[8] PROGMEM = {0x02, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0x01};
5-
uint8_t default_server_name[16] PROGMEM = "ATMEGA128rfa1";
6-
uint8_t default_domain_name[30] PROGMEM = "localhost";
4+
const uint8_t default_mac_address[8] PROGMEM = {0x02, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0x01};
5+
const uint8_t default_server_name[16] PROGMEM = "ATMEGA128rfa1";
6+
const uint8_t default_domain_name[30] PROGMEM = "localhost";
77
uint8_t eemem_mac_address[8] EEMEM = {0x02, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0x01};
88
uint8_t eemem_server_name[16] EEMEM = "ATMEGA128rfa1";
99
uint8_t eemem_domain_name[30] EEMEM = "localhost";

platform/avr-atmega128rfa1/apps/raven-webserver/httpd-fsdata.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55

66
/* Link layer ipv6 address will become fe80::ff:fe:1 */
7-
uint8_t default_mac_address[8] PROGMEM = {0x02, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0x01};
8-
uint8_t default_server_name[16] PROGMEM = "ATMEGA128rfa1";
9-
uint8_t default_domain_name[30] PROGMEM = "localhost";
7+
const uint8_t default_mac_address[8] PROGMEM = {0x02, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0x01};
8+
const uint8_t default_server_name[16] PROGMEM = "ATMEGA128rfa1";
9+
const uint8_t default_domain_name[30] PROGMEM = "localhost";
1010
uint8_t eemem_mac_address[8] EEMEM = {0x02, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0x01};
1111
uint8_t eemem_server_name[16] EEMEM = "ATMEGA128rfa1";
1212
uint8_t eemem_domain_name[30] EEMEM = "localhost";

platform/avr-raven/apps/raven-webserver/httpd-fs/makefsdata.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include <avr/eeprom.h>
22

33
/* Link layer ipv6 address will become fe80::11:22ff:fe33:4455 */
4-
uint8_t default_mac_address[8] PROGMEM = {0x02, 0x11, 0x22, 0xff, 0xfe, 0x33, 0x44, 0x55};
5-
uint8_t default_server_name[16] PROGMEM = "Contiki-Raven";
6-
uint8_t default_domain_name[30] PROGMEM = "localhost";
4+
const uint8_t default_mac_address[8] PROGMEM = {0x02, 0x11, 0x22, 0xff, 0xfe, 0x33, 0x44, 0x55};
5+
const uint8_t default_server_name[16] PROGMEM = "Contiki-Raven";
6+
const uint8_t default_domain_name[30] PROGMEM = "localhost";
77
uint8_t eemem_mac_address[8] EEMEM = {0x02, 0x11, 0x22, 0xff, 0xfe, 0x33, 0x44, 0x55};
88
uint8_t eemem_server_name[16] EEMEM = "Contiki-Raven";
99
uint8_t eemem_domain_name[30] EEMEM = "localhost";

platform/avr-raven/apps/raven-webserver/httpd.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,6 @@ generate_header(void *hstr)
307307
#endif
308308
}
309309
/*---------------------------------------------------------------------------*/
310-
char http_htm[10] PROGMEM ="text/html";
311-
char http_css[ 9] PROGMEM ="text/css";
312310
const char httpd_mime_htm[] HTTPD_STRING_ATTR = "text/html";
313311
const char httpd_mime_css[] HTTPD_STRING_ATTR = "text/css";
314312
const char httpd_mime_png[] HTTPD_STRING_ATTR = "image/png";

platform/z1/contiki-z1-main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ main(int argc, char **argv)
220220
node_id_restore();
221221

222222
/* If no MAC address was burned, we use the node ID. */
223-
if(node_mac[0] | node_mac[1] | node_mac[2] | node_mac[3] |
224-
node_mac[4] | node_mac[5] | node_mac[6] | node_mac[7]) {
223+
if(!(node_mac[0] | node_mac[1] | node_mac[2] | node_mac[3] |
224+
node_mac[4] | node_mac[5] | node_mac[6] | node_mac[7])) {
225225
node_mac[0] = 0xc1; /* Hardcoded for Z1 */
226226
node_mac[1] = 0x0c; /* Hardcoded for Revision C */
227227
node_mac[2] = 0x00; /* Hardcoded to arbitrary even number so that

tools/cooja/apps/mspsim/exp5438.png

100755100644
File mode changed.

tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/Z1MoteType.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import se.sics.cooja.interfaces.Position;
4040
import se.sics.cooja.interfaces.RimeAddress;
4141
import se.sics.cooja.mspmote.interfaces.Msp802154Radio;
42+
import se.sics.cooja.mspmote.interfaces.MspButton;
4243
import se.sics.cooja.mspmote.interfaces.MspClock;
4344
import se.sics.cooja.mspmote.interfaces.MspDebugOutput;
4445
import se.sics.cooja.mspmote.interfaces.MspDefaultSerial;
@@ -80,6 +81,7 @@ public Class<? extends MoteInterface>[] getAllMoteInterfaceClasses() {
8081
MoteAttributes.class,
8182
MspClock.class,
8283
MspMoteID.class,
84+
MspButton.class,
8385
// SkyFlash.class,
8486
Msp802154Radio.class,
8587
MspDefaultSerial.class,

tools/cooja/apps/mspsim/tyndall.png

100755100644
File mode changed.

tools/cooja/config/external_tools.config

100755100644
File mode changed.

tools/cooja/java/se/sics/cooja/GUI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4479,7 +4479,7 @@ public boolean shouldBeEnabled() {
44794479
return getSimulation() != null;
44804480
}
44814481
};
4482-
GUIAction exitCoojaAction = new GUIAction("Exit") {
4482+
GUIAction exitCoojaAction = new GUIAction("Exit", 'x') {
44834483
private static final long serialVersionUID = 7523822251658687665L;
44844484
public void actionPerformed(ActionEvent e) {
44854485
myGUI.doQuit(true);

tools/cooja/java/se/sics/cooja/HasQuickHelp.java

100755100644
File mode changed.

tools/cooja/java/se/sics/cooja/MoteInterfaceHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ public MoteInterfaceHandler(Mote mote, Class<? extends MoteInterface>[] interfac
105105
*/
106106
public <N extends MoteInterface> N getInterfaceOfType(Class<N> interfaceType) {
107107
for (MoteInterface intf : moteInterfaces) {
108-
if (interfaceType.isAssignableFrom(intf.getClass())) {
109-
return (N) intf;
108+
if (interfaceType.isInstance(intf)) {
109+
return interfaceType.cast(intf);
110110
}
111111
}
112112

0 commit comments

Comments
 (0)