Code style fixes: cc2530dk examples
This commit is contained in:
parent
351a4d39b9
commit
594ba9a0ed
10 changed files with 38 additions and 35 deletions
|
@ -33,7 +33,7 @@ PROCESS_THREAD(hello_world_process, ev, data)
|
||||||
|
|
||||||
if(ev == PROCESS_EVENT_TIMER) {
|
if(ev == PROCESS_EVENT_TIMER) {
|
||||||
printf("Sensor says #%u\n", count);
|
printf("Sensor says #%u\n", count);
|
||||||
count ++;
|
count++;
|
||||||
|
|
||||||
etimer_reset(&et_hello);
|
etimer_reset(&et_hello);
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ print_local_addresses(void) CC_NON_BANKED
|
||||||
PUTSTRING(" ");
|
PUTSTRING(" ");
|
||||||
PRINT6ADDR(&uip_ds6_if.addr_list[i].ipaddr);
|
PRINT6ADDR(&uip_ds6_if.addr_list[i].ipaddr);
|
||||||
PUTCHAR('\n');
|
PUTCHAR('\n');
|
||||||
if (state == ADDR_TENTATIVE) {
|
if(state == ADDR_TENTATIVE) {
|
||||||
uip_ds6_if.addr_list[i].state = ADDR_PREFERRED;
|
uip_ds6_if.addr_list[i].state = ADDR_PREFERRED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ static void
|
||||||
slip_input_callback(void)
|
slip_input_callback(void)
|
||||||
{
|
{
|
||||||
PRINTF("SIN: %u\n", uip_len);
|
PRINTF("SIN: %u\n", uip_len);
|
||||||
if((char) uip_buf[0] == '!') {
|
if((char)uip_buf[0] == '!') {
|
||||||
PRINTF("Got configuration message of type %c\n", uip_buf[1]);
|
PRINTF("Got configuration message of type %c\n", uip_buf[1]);
|
||||||
uip_len = 0;
|
uip_len = 0;
|
||||||
if((char)uip_buf[1] == 'P') {
|
if((char)uip_buf[1] == 'P') {
|
||||||
|
|
|
@ -91,7 +91,7 @@ PROCESS_THREAD(buttons_test_process, ev, data)
|
||||||
|
|
||||||
PROCESS_BEGIN();
|
PROCESS_BEGIN();
|
||||||
|
|
||||||
while (1) {
|
while(1) {
|
||||||
|
|
||||||
PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event);
|
PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event);
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ PROCESS_THREAD(sensors_test_process, ev, data)
|
||||||
|
|
||||||
/* Sensor Values */
|
/* Sensor Values */
|
||||||
static int rv;
|
static int rv;
|
||||||
static struct sensors_sensor * sensor;
|
static struct sensors_sensor *sensor;
|
||||||
static float sane = 0;
|
static float sane = 0;
|
||||||
static int dec;
|
static int dec;
|
||||||
static float frac;
|
static float frac;
|
||||||
|
@ -127,7 +127,7 @@ PROCESS_THREAD(sensors_test_process, ev, data)
|
||||||
/* Set an etimer. We take sensor readings when it expires and reset it. */
|
/* Set an etimer. We take sensor readings when it expires and reset it. */
|
||||||
etimer_set(&et, CLOCK_SECOND * 2);
|
etimer_set(&et, CLOCK_SECOND * 2);
|
||||||
|
|
||||||
while (1) {
|
while(1) {
|
||||||
|
|
||||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ PROCESS_THREAD(sensors_test_process, ev, data)
|
||||||
* Return value -1 means sensor not available or turned off in conf
|
* Return value -1 means sensor not available or turned off in conf
|
||||||
*/
|
*/
|
||||||
sensor = sensors_find(ADC_SENSOR);
|
sensor = sensors_find(ADC_SENSOR);
|
||||||
if (sensor) {
|
if(sensor) {
|
||||||
PRINTF("------------------\n");
|
PRINTF("------------------\n");
|
||||||
leds_on(LEDS_RED);
|
leds_on(LEDS_RED);
|
||||||
/*
|
/*
|
||||||
|
@ -189,5 +189,5 @@ PROCESS_THREAD(sensors_test_process, ev, data)
|
||||||
etimer_reset(&et);
|
etimer_reset(&et);
|
||||||
}
|
}
|
||||||
PROCESS_END();
|
PROCESS_END();
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -47,4 +47,3 @@ netstack_init(void)
|
||||||
NETSTACK_RADIO.init();
|
NETSTACK_RADIO.init();
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,8 @@ AUTOSTART_PROCESSES(&clock_test_process);
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#if TEST_RTIMER
|
#if TEST_RTIMER
|
||||||
void
|
void
|
||||||
rt_callback(struct rtimer *t, void *ptr) {
|
rt_callback(struct rtimer *t, void *ptr)
|
||||||
|
{
|
||||||
rt_now = RTIMER_NOW();
|
rt_now = RTIMER_NOW();
|
||||||
ct = clock_time();
|
ct = clock_time();
|
||||||
printf("Task called at %u (clock = %u)\n", rt_now, ct);
|
printf("Task called at %u (clock = %u)\n", rt_now, ct);
|
||||||
|
@ -82,13 +83,13 @@ PROCESS_THREAD(clock_test_process, ev, data)
|
||||||
printf("Rtimer Test, 1 sec (%u rtimer ticks):\n", RTIMER_SECOND);
|
printf("Rtimer Test, 1 sec (%u rtimer ticks):\n", RTIMER_SECOND);
|
||||||
i = 0;
|
i = 0;
|
||||||
while(i < 5) {
|
while(i < 5) {
|
||||||
etimer_set(&et, 2*CLOCK_SECOND);
|
etimer_set(&et, 2 * CLOCK_SECOND);
|
||||||
printf("=======================\n");
|
printf("=======================\n");
|
||||||
ct = clock_time();
|
ct = clock_time();
|
||||||
rt_now = RTIMER_NOW();
|
rt_now = RTIMER_NOW();
|
||||||
rt_for = rt_now + RTIMER_SECOND;
|
rt_for = rt_now + RTIMER_SECOND;
|
||||||
printf("Now=%u (clock = %u) - For=%u\n", rt_now, ct, rt_for);
|
printf("Now=%u (clock = %u) - For=%u\n", rt_now, ct, rt_for);
|
||||||
if (rtimer_set(&rt, rt_for, 1,
|
if(rtimer_set(&rt, rt_for, 1,
|
||||||
(void (*)(struct rtimer *, void *))rt_callback, NULL) != RTIMER_OK) {
|
(void (*)(struct rtimer *, void *))rt_callback, NULL) != RTIMER_OK) {
|
||||||
printf("Error setting\n");
|
printf("Error setting\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ static void
|
||||||
timeout_handler(void)
|
timeout_handler(void)
|
||||||
{
|
{
|
||||||
static int seq_id;
|
static int seq_id;
|
||||||
struct uip_udp_conn * this_conn;
|
struct uip_udp_conn *this_conn;
|
||||||
|
|
||||||
leds_on(LEDS_RED);
|
leds_on(LEDS_RED);
|
||||||
memset(buf, 0, MAX_PAYLOAD_LEN);
|
memset(buf, 0, MAX_PAYLOAD_LEN);
|
||||||
|
@ -117,7 +117,7 @@ PROCESS_THREAD(udp_client_process, ev, data)
|
||||||
PROCESS_BEGIN();
|
PROCESS_BEGIN();
|
||||||
PRINTF("UDP client process started\n");
|
PRINTF("UDP client process started\n");
|
||||||
|
|
||||||
uip_ip6addr(&ipaddr,0xfe80,0,0,0,0x0215,0x2000,0x0002,0x2145);
|
uip_ip6addr(&ipaddr, 0xfe80, 0, 0, 0, 0x0215, 0x2000, 0x0002, 0x2145);
|
||||||
/* new connection with remote host */
|
/* new connection with remote host */
|
||||||
l_conn = udp_new(&ipaddr, UIP_HTONS(3000), NULL);
|
l_conn = udp_new(&ipaddr, UIP_HTONS(3000), NULL);
|
||||||
if(!l_conn) {
|
if(!l_conn) {
|
||||||
|
@ -130,7 +130,7 @@ PROCESS_THREAD(udp_client_process, ev, data)
|
||||||
PRINTF(" local/remote port %u/%u\n",
|
PRINTF(" local/remote port %u/%u\n",
|
||||||
UIP_HTONS(l_conn->lport), UIP_HTONS(l_conn->rport));
|
UIP_HTONS(l_conn->lport), UIP_HTONS(l_conn->rport));
|
||||||
|
|
||||||
uip_ip6addr(&ipaddr,0xaaaa,0,0,0,0x0215,0x2000,0x0002,0x2145);
|
uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0x0215, 0x2000, 0x0002, 0x2145);
|
||||||
g_conn = udp_new(&ipaddr, UIP_HTONS(3000), NULL);
|
g_conn = udp_new(&ipaddr, UIP_HTONS(3000), NULL);
|
||||||
if(!g_conn) {
|
if(!g_conn) {
|
||||||
PRINTF("udp_new g_conn error.\n");
|
PRINTF("udp_new g_conn error.\n");
|
||||||
|
|
|
@ -72,7 +72,8 @@ ping6handler()
|
||||||
count, PING6_DATALEN);
|
count, PING6_DATALEN);
|
||||||
|
|
||||||
|
|
||||||
uip_len = UIP_ICMPH_LEN + UIP_ICMP6_ECHO_REQUEST_LEN + UIP_IPH_LEN + PING6_DATALEN;
|
uip_len = UIP_ICMPH_LEN + UIP_ICMP6_ECHO_REQUEST_LEN + UIP_IPH_LEN
|
||||||
|
+ PING6_DATALEN;
|
||||||
UIP_IP_BUF->len[0] = (uint8_t)((uip_len - 40) >> 8);
|
UIP_IP_BUF->len[0] = (uint8_t)((uip_len - 40) >> 8);
|
||||||
UIP_IP_BUF->len[1] = (uint8_t)((uip_len - 40) & 0x00FF);
|
UIP_IP_BUF->len[1] = (uint8_t)((uip_len - 40) & 0x00FF);
|
||||||
|
|
||||||
|
@ -104,7 +105,7 @@ PROCESS_THREAD(ping6_process, ev, data)
|
||||||
PRINTF("ping6 running.\n");
|
PRINTF("ping6 running.\n");
|
||||||
PRINTF("Button 1: 5 pings 16 byte payload.\n");
|
PRINTF("Button 1: 5 pings 16 byte payload.\n");
|
||||||
|
|
||||||
uip_ip6addr(&dest_addr,0xaaaa,0,0,0,0x0215,0x2000,0x0002,0x2145);
|
uip_ip6addr(&dest_addr, 0xaaaa, 0, 0, 0, 0x0215, 0x2000, 0x0002, 0x2145);
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
icmp6_new(NULL);
|
icmp6_new(NULL);
|
||||||
|
|
|
@ -92,9 +92,10 @@ static void
|
||||||
print_stats()
|
print_stats()
|
||||||
{
|
{
|
||||||
PRINTF("tl=%lu, ts=%lu, bs=%lu, bc=%lu\n",
|
PRINTF("tl=%lu, ts=%lu, bs=%lu, bc=%lu\n",
|
||||||
rimestats.toolong, rimestats.tooshort, rimestats.badsynch, rimestats.badcrc);
|
rimestats.toolong, rimestats.tooshort, rimestats.badsynch,
|
||||||
PRINTF("llrx=%lu, lltx=%lu, rx=%lu, tx=%lu\n",
|
rimestats.badcrc);
|
||||||
rimestats.llrx, rimestats.lltx, rimestats.rx, rimestats.tx);
|
PRINTF("llrx=%lu, lltx=%lu, rx=%lu, tx=%lu\n", rimestats.llrx,
|
||||||
|
rimestats.lltx, rimestats.rx, rimestats.tx);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
@ -112,7 +113,7 @@ print_local_addresses(void)
|
||||||
PRINTF(" ");
|
PRINTF(" ");
|
||||||
PRINT6ADDR(&uip_ds6_if.addr_list[i].ipaddr);
|
PRINT6ADDR(&uip_ds6_if.addr_list[i].ipaddr);
|
||||||
PRINTF("\n");
|
PRINTF("\n");
|
||||||
if (state == ADDR_TENTATIVE) {
|
if(state == ADDR_TENTATIVE) {
|
||||||
uip_ds6_if.addr_list[i].state = ADDR_PREFERRED;
|
uip_ds6_if.addr_list[i].state = ADDR_PREFERRED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,7 +132,8 @@ create_dag()
|
||||||
|
|
||||||
print_local_addresses();
|
print_local_addresses();
|
||||||
|
|
||||||
dag = rpl_set_root(RPL_DEFAULT_INSTANCE, &uip_ds6_get_global(ADDR_PREFERRED)->ipaddr);
|
dag = rpl_set_root(RPL_DEFAULT_INSTANCE,
|
||||||
|
&uip_ds6_get_global(ADDR_PREFERRED)->ipaddr);
|
||||||
if(dag != NULL) {
|
if(dag != NULL) {
|
||||||
uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
|
uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
|
||||||
rpl_set_prefix(dag, &ipaddr, 64);
|
rpl_set_prefix(dag, &ipaddr, 64);
|
||||||
|
|
Loading…
Reference in a new issue