Commit 50642b3e authored by Joakim Eriksson's avatar Joakim Eriksson
Browse files

removed unused code and sensors on Sky slip-radio

parent 21a1a2e2
......@@ -32,7 +32,5 @@
#define QUEUEBUF_CONF_NUM 4
#define UIP_CONF_BUFFER_SIZE 140
#define CMD_CONF_HANDLERS slip_radio_cmd_handler,cmd_handler_cc2420
#define SLIP_RADIO_CONF_SENSORS slip_radio_sky_sensors
#define UART1_CONF_RX_WITH_DMA 1
/*---------------------------------------------------------------------------*/
/*
* Copyright (c) 2011, 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.
*
* Sets up some commands for the CC2420 radio chip.
*/
#include "contiki.h"
#include "cc2420.h"
#include "cmd.h"
#include <stdio.h>
int
cmd_handler_cc2420(const uint8_t *data, int len)
{
if(data[0] == '!') {
if(data[1] == 'C') {
printf("cc2420_cmd: setting channel: %d\n", data[2]);
cc2420_set_channel(data[2]);
return 1;
}
} else if(data[0] == '?') {
if(data[1] == 'C') {
uint8_t buf[4];
printf("cc2420_cmd: getting channel: %d\n", data[2]);
buf[0] = '!';
buf[1] = 'C';
buf[2] = cc2420_get_channel();
cmd_send(buf, 3);
return 1;
}
}
return 0;
}
/*
* Copyright (c) 2011, 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.
*/
#include "contiki.h"
#include "lib/sensors.h"
#include "dev/sht11/sht11-sensor.h"
#include "slip-radio.h"
#include "cmd.h"
#include <stdio.h>
/*---------------------------------------------------------------------------*/
static void
init(void)
{
}
/*---------------------------------------------------------------------------*/
static int
write_percent_float(char *data, int maxlen, int temp)
{
int t;
t = temp % 100;
if(t < 0) {
t = -t;
}
return snprintf(data, maxlen, "%d.%02d", temp / 100, t);
}
/*---------------------------------------------------------------------------*/
static void
send(void)
{
#define MAX_SIZE 40
char data[MAX_SIZE];
int temperature;
int ms;
long hum;
int pos = 0;
/* SENSORS_ACTIVATE(light_sensor); */
SENSORS_ACTIVATE(sht11_sensor);
pos += snprintf(data, MAX_SIZE, "!D");
/* int light1 = light_sensor.value(LIGHT_SENSOR_PHOTOSYNTHETIC); */
/* int light2 = light_sensor.value(LIGHT_SENSOR_TOTAL_SOLAR); */
temperature = -3970 + sht11_sensor.value(SHT11_SENSOR_TEMP);
ms = sht11_sensor.value(SHT11_SENSOR_HUMIDITY);
/* this is in * 10000 */
/* -2.0468 + 0.0367 * ms + -1.5955e-6 * ms * ms ...too small value... */
hum = (-20468L + 367L * ms) / 100L;
/* SENSORS_DEACTIVATE(light_sensor); */
SENSORS_DEACTIVATE(sht11_sensor);
pos += snprintf(&data[pos], MAX_SIZE - pos, "temp=");
pos += write_percent_float(&data[pos], MAX_SIZE - pos, temperature);
pos += snprintf(&data[pos], MAX_SIZE - pos, ";hum=");
pos += write_percent_float(&data[pos], MAX_SIZE - pos, hum);
cmd_send((uint8_t *)data, pos);
}
/* ---------------------------------------------------------------------- */
const struct slip_radio_sensors slip_radio_sky_sensors = {
init, send
};
/* ---------------------------------------------------------------------- */
......@@ -227,7 +227,9 @@ static void
slip_input_callback(void)
{
LOG_DBG("SR-SIN: %u '%c%c'\n", uip_len, uip_buf[0], uip_buf[1]);
cmd_input(uip_buf, uip_len);
if(!cmd_input(uip_buf, uip_len)) {
cmd_send((uint8_t *)"EUnknown command", 16);
}
uip_clear_buf();
}
/*---------------------------------------------------------------------------*/
......
......@@ -44,6 +44,7 @@
#include "net/ipv6/uiplib.h"
#include <string.h>
#include "shell.h"
#include <stdio.h>
#define DEBUG DEBUG_NONE
#include "net/ipv6/uip-debug.h"
......@@ -243,7 +244,6 @@ PROCESS_THREAD(border_router_cmd_process, ev, data)
/* Commnand executed - all is fine */
} else {
/* did not find command - run shell and see if ... */
// FOR SERIAL RADIO cmd_send((uint8_t *)"EUnknown command", 16);
PROCESS_PT_SPAWN(&shell_input_pt, shell_input(&shell_input_pt, serial_shell_output, data));
}
}
......
......@@ -51,18 +51,11 @@
#include <stdlib.h>
#define MAX_SENSORS 4
extern long slip_sent;
extern long slip_received;
static uint8_t mac_set;
static uint8_t sensor_count = 0;
/* allocate MAX_SENSORS char[32]'s */
static char sensors[MAX_SENSORS][32];
extern int contiki_argc;
extern char **contiki_argv;
extern const char *slip_config_ipaddr;
......@@ -101,30 +94,6 @@ border_router_print_stat()
printf("bytes sent over SLIP: %ld\n", slip_sent);
}
/*---------------------------------------------------------------------------*/
/* Format: <name=value>;<name=value>;...;<name=value>*/
/* this function just cut at ; and store in the sensor array */
void
border_router_set_sensors(const char *data, int len)
{
int i;
int last_pos = 0;
int sc = 0;
for(i = 0; i < len; i++) {
if(data[i] == ';') {
sensors[sc][i - last_pos] = 0;
memcpy(sensors[sc++], &data[last_pos], i - last_pos);
last_pos = i + 1; /* skip the ';' */
}
if(sc == MAX_SENSORS) {
sensor_count = sc;
return;
}
}
sensors[sc][len - last_pos] = 0;
memcpy(sensors[sc++], &data[last_pos], len - last_pos);
sensor_count = sc;
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(border_router_process, ev, data)
{
static struct etimer et;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment