change plattform to osd-merkur
This commit is contained in:
parent
33639c15e1
commit
5ee13bf528
8 changed files with 15 additions and 4871 deletions
|
@ -1,7 +1,14 @@
|
||||||
A Quick Introduction to the Erbium (Er) REST Engine
|
A Quick Introduction to the Erbium (Er) REST Engine
|
||||||
===================================================
|
===================================================
|
||||||
|
Compile the Example
|
||||||
|
-------------------
|
||||||
|
./run.sh
|
||||||
|
|
||||||
sudo avrdude -pm128rfa1 -c arduino -P/dev/ttyUSB0 -b57600 -e -U flash:w:er-example-server.osd-er-lp24.hex:a -U eeprom:w:er-example-server.osd-er-lp24.eep:a
|
OSD-Merkur Board
|
||||||
|
----------------------
|
||||||
|
write the images to the OSD-Merkur Board:
|
||||||
|
|
||||||
|
./flash.sh
|
||||||
|
|
||||||
EXAMPLE FILES
|
EXAMPLE FILES
|
||||||
-------------
|
-------------
|
||||||
|
@ -40,25 +47,6 @@ With client:
|
||||||
4) Wait until red LED toggles on mote 2 (server)
|
4) Wait until red LED toggles on mote 2 (server)
|
||||||
5) Choose "Click button on Sky 3" from the context menu of mote 3 (client) and watch serial output
|
5) Choose "Click button on Sky 3" from the context menu of mote 3 (client) and watch serial output
|
||||||
|
|
||||||
TMOTES HOWTO
|
|
||||||
------------
|
|
||||||
Server:
|
|
||||||
1) Connect two Tmote Skys (check with $ make TARGET=sky sky-motelist)
|
|
||||||
2) $ make TARGET=sky er-example-server.upload MOTE=2
|
|
||||||
3) $ make TARGET=sky login MOTE=2
|
|
||||||
4) Press reset button, get address, abort with Ctrl+C:
|
|
||||||
Line: "Tentative link-local IPv6 address fe80:0000:0000:0000:____:____:____:____"
|
|
||||||
5) $ cd ../ipv6/rpl-border-router/
|
|
||||||
6) $ make TARGET=sky border-router.upload MOTE=1
|
|
||||||
7) $ make connect-router
|
|
||||||
For a BR tty other than USB0: $ make connect-router-port PORT=X
|
|
||||||
8) Start Copper and discover resources at coap://[aaaa::____:____:____:____]:5683/
|
|
||||||
|
|
||||||
Add a client:
|
|
||||||
1) Change the hard-coded server address in er-example-client.c to aaaa::____:____:____:____
|
|
||||||
2) Connect a third Tmote Sky
|
|
||||||
3) $ make TARGET=sky er-example-client.upload MOTE=3
|
|
||||||
|
|
||||||
DETAILS
|
DETAILS
|
||||||
-------
|
-------
|
||||||
Erbium currently implements draft 08 (name "er-coap-07" stems from last technical draft changes).
|
Erbium currently implements draft 08 (name "er-coap-07" stems from last technical draft changes).
|
||||||
|
|
|
@ -1,173 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2011, Matthias Kovatsch and other contributors.
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file
|
|
||||||
* Erbium (Er) CoAP client example
|
|
||||||
* \author
|
|
||||||
* Matthias Kovatsch <kovatsch@inf.ethz.ch>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "contiki.h"
|
|
||||||
#include "contiki-net.h"
|
|
||||||
|
|
||||||
#if !UIP_CONF_IPV6_RPL && !defined (CONTIKI_TARGET_MINIMAL_NET) && !defined (CONTIKI_TARGET_NATIVE)
|
|
||||||
#warning "Compiling with static routing!"
|
|
||||||
#include "static-routing.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "dev/button-sensor.h"
|
|
||||||
|
|
||||||
#if WITH_COAP == 3
|
|
||||||
#include "er-coap-03-engine.h"
|
|
||||||
#elif WITH_COAP == 6
|
|
||||||
#include "er-coap-06-engine.h"
|
|
||||||
#elif WITH_COAP == 7
|
|
||||||
#include "er-coap-07-engine.h"
|
|
||||||
#else
|
|
||||||
#error "CoAP version defined by WITH_COAP not implemented"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#define DEBUG 0
|
|
||||||
#if DEBUG
|
|
||||||
#define PRINTF(...) printf(__VA_ARGS__)
|
|
||||||
#define PRINT6ADDR(addr) PRINTF("[%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x]", ((uint8_t *)addr)[0], ((uint8_t *)addr)[1], ((uint8_t *)addr)[2], ((uint8_t *)addr)[3], ((uint8_t *)addr)[4], ((uint8_t *)addr)[5], ((uint8_t *)addr)[6], ((uint8_t *)addr)[7], ((uint8_t *)addr)[8], ((uint8_t *)addr)[9], ((uint8_t *)addr)[10], ((uint8_t *)addr)[11], ((uint8_t *)addr)[12], ((uint8_t *)addr)[13], ((uint8_t *)addr)[14], ((uint8_t *)addr)[15])
|
|
||||||
#define PRINTLLADDR(lladdr) PRINTF("[%02x:%02x:%02x:%02x:%02x:%02x]",(lladdr)->addr[0], (lladdr)->addr[1], (lladdr)->addr[2], (lladdr)->addr[3],(lladdr)->addr[4], (lladdr)->addr[5])
|
|
||||||
#else
|
|
||||||
#define PRINTF(...)
|
|
||||||
#define PRINT6ADDR(addr)
|
|
||||||
#define PRINTLLADDR(addr)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* TODO: This server address is hard-coded for Cooja. */
|
|
||||||
#define SERVER_NODE(ipaddr) uip_ip6addr(ipaddr, 0xaaaa, 0, 0, 0, 0x0212, 0x7402, 0x0002, 0x0202) /* cooja2 */
|
|
||||||
|
|
||||||
#define LOCAL_PORT UIP_HTONS(COAP_DEFAULT_PORT+1)
|
|
||||||
#define REMOTE_PORT UIP_HTONS(COAP_DEFAULT_PORT)
|
|
||||||
|
|
||||||
#define TOGGLE_INTERVAL 10
|
|
||||||
|
|
||||||
PROCESS(coap_client_example, "COAP Client Example");
|
|
||||||
AUTOSTART_PROCESSES(&coap_client_example);
|
|
||||||
|
|
||||||
|
|
||||||
uip_ipaddr_t server_ipaddr;
|
|
||||||
static struct etimer et;
|
|
||||||
|
|
||||||
/* Example URIs that can be queried. */
|
|
||||||
#define NUMBER_OF_URLS 4
|
|
||||||
/* leading and ending slashes only for demo purposes, get cropped automatically when setting the Uri-Path */
|
|
||||||
char* service_urls[NUMBER_OF_URLS] = {".well-known/core", "/actuators/toggle", "battery/", "error/in//path"};
|
|
||||||
#if PLATFORM_HAS_BUTTON
|
|
||||||
static int uri_switch = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* This function is will be passed to COAP_BLOCKING_REQUEST() to handle responses. */
|
|
||||||
void
|
|
||||||
client_chunk_handler(void *response)
|
|
||||||
{
|
|
||||||
uint8_t *chunk;
|
|
||||||
|
|
||||||
int len = coap_get_payload(response, &chunk);
|
|
||||||
printf("|%.*s", len, (char *)chunk);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PROCESS_THREAD(coap_client_example, ev, data)
|
|
||||||
{
|
|
||||||
PROCESS_BEGIN();
|
|
||||||
|
|
||||||
static coap_packet_t request[1]; /* This way the packet can be treated as pointer as usual. */
|
|
||||||
SERVER_NODE(&server_ipaddr);
|
|
||||||
|
|
||||||
/* receives all CoAP messages */
|
|
||||||
coap_receiver_init();
|
|
||||||
|
|
||||||
etimer_set(&et, TOGGLE_INTERVAL * CLOCK_SECOND);
|
|
||||||
|
|
||||||
#if PLATFORM_HAS_BUTTON
|
|
||||||
SENSORS_ACTIVATE(button_sensor);
|
|
||||||
printf("Press a button to request %s\n", service_urls[uri_switch]);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while(1) {
|
|
||||||
PROCESS_YIELD();
|
|
||||||
|
|
||||||
if (etimer_expired(&et)) {
|
|
||||||
printf("--Toggle timer--\n");
|
|
||||||
|
|
||||||
/* prepare request, TID is set by COAP_BLOCKING_REQUEST() */
|
|
||||||
coap_init_message(request, COAP_TYPE_CON, COAP_POST, 0 );
|
|
||||||
coap_set_header_uri_path(request, service_urls[1]);
|
|
||||||
|
|
||||||
const char msg[] = "Toggle!";
|
|
||||||
coap_set_payload(request, (uint8_t *)msg, sizeof(msg)-1);
|
|
||||||
|
|
||||||
|
|
||||||
PRINT6ADDR(&server_ipaddr);
|
|
||||||
PRINTF(" : %u\n", UIP_HTONS(REMOTE_PORT));
|
|
||||||
|
|
||||||
COAP_BLOCKING_REQUEST(&server_ipaddr, REMOTE_PORT, request, client_chunk_handler);
|
|
||||||
|
|
||||||
printf("\n--Done--\n");
|
|
||||||
|
|
||||||
etimer_reset(&et);
|
|
||||||
|
|
||||||
#if PLATFORM_HAS_BUTTON
|
|
||||||
} else if (ev == sensors_event && data == &button_sensor) {
|
|
||||||
|
|
||||||
/* send a request to notify the end of the process */
|
|
||||||
|
|
||||||
coap_init_message(request, COAP_TYPE_CON, COAP_GET, 0);
|
|
||||||
coap_set_header_uri_path(request, service_urls[uri_switch]);
|
|
||||||
|
|
||||||
printf("--Requesting %s--\n", service_urls[uri_switch]);
|
|
||||||
|
|
||||||
PRINT6ADDR(&server_ipaddr);
|
|
||||||
PRINTF(" : %u\n", UIP_HTONS(REMOTE_PORT));
|
|
||||||
|
|
||||||
COAP_BLOCKING_REQUEST(&server_ipaddr, REMOTE_PORT, request, client_chunk_handler);
|
|
||||||
|
|
||||||
printf("\n--Done--\n");
|
|
||||||
|
|
||||||
uri_switch = (uri_switch+1) % NUMBER_OF_URLS;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PROCESS_END();
|
|
||||||
}
|
|
Binary file not shown.
Binary file not shown.
|
@ -1,4 +0,0 @@
|
||||||
:10000000020000FFFE00000341544D4547413132DC
|
|
||||||
:100010003872666131006C6F63616C686F73740075
|
|
||||||
:0900200000001AE5CDAB00000060
|
|
||||||
:00000001FF
|
|
File diff suppressed because it is too large
Load diff
2
examples/osd/wirelessplug/flash.sh
Executable file
2
examples/osd/wirelessplug/flash.sh
Executable file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/bash
|
||||||
|
sudo avrdude -pm128rfa1 -c arduino -P/dev/ttyUSB0 -b57600 -e -U flash:w:er-example-server.osd-merkur.hex:a -U eeprom:w:er-example-server.osd-merkur.eep:a
|
|
@ -1,7 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
make clean TARGET=osd-er-lp24
|
make clean TARGET=osd-merkur
|
||||||
make TARGET=osd-er-lp24
|
make TARGET=osd-merkur
|
||||||
avr-size -C --mcu=MCU=atmega128rfa1 er-example-server.osd-er-lp24
|
avr-size -C --mcu=MCU=atmega128rfa1 er-example-server.osd-merkur
|
||||||
avr-objcopy -j .text -j .data -O ihex er-example-server.osd-er-lp24 er-example-server.osd-er-lp24.hex
|
avr-objcopy -j .text -j .data -O ihex er-example-server.osd-merkur er-example-server.osd-merkur.hex
|
||||||
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex er-example-server.osd-er-lp24 er-example-server.osd-er-lp24.eep
|
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex er-example-server.osd-merkur er-example-server.osd-merkur.eep
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue