Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestLinkLocalC compilation Problem Solved #303

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/PppRouter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ PFLAGS += -DPPP_HDLC_TX_FRAME_LIMIT=8
### Configure printf() output
################################################################################

PFLAGS += -DNEW_PRINTF_SEMANTICS -DPRINTFUART_ENABLED
#PFLAGS += -DNEW_PRINTF_SEMANTICS -DPRINTFUART_ENABLED

################################################################################
### Configure this application
Expand Down
4 changes: 4 additions & 0 deletions apps/PppRouter/PppRouterC.nc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ configuration PppRouterC {
PppDaemonC.HdlcUart -> HdlcUartC;
PppDaemonC.UartControl -> HdlcUartC;

#if defined(PRINTFUART_ENABLED)
components PrintfC,SerialStartC;
#endif

// SDH : don't bother including the PppPrintfC by default
// components PppPrintfC, PppC;;
// PppPrintfC.Ppp -> PppDaemonC;
Expand Down
13 changes: 13 additions & 0 deletions apps/RadioCountToLeds1/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
COMPONENT=RadioCountToLedsAppC
CFLAGS+=-DCC2520_HW_ACKNOWLEDGEMENTS
CFLAGS+=-DCC2520_HW_SECURITY
CFLAGS+=-DPRINTF_BUFFER_SIZE=500
CFLAGS+=-DCC2520_DEF_CHANNEL=22
CFLAGS+=-DTFRAMES_ENABLED
CFLAGS+=-DPACKET_LINK
CFLAGS+=-DTOSH_DATA_LENGTH=50
#CFLAGS+=-I%T/lib/printf
CFLAGS+=-I$(TOSDIR)/lib/printf
CFLAGS+=-DPRINTFUART_ENABLED
CFLAGS+=-I./
include $(MAKERULES)
52 changes: 52 additions & 0 deletions apps/RadioCountToLeds1/RadioCountToLeds.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - 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.
* - Neither the name of the copyright holders 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/

#ifndef RADIO_COUNT_TO_LEDS_H
#define RADIO_COUNT_TO_LEDS_H

typedef nx_struct radio_count_msg {
nx_uint16_t counter;
} radio_count_msg_t;

enum {
AM_RADIO_COUNT_MSG = 6,
};

#endif
83 changes: 83 additions & 0 deletions apps/RadioCountToLeds1/RadioCountToLedsAppC.nc
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Copyright (c) 2000-2005 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - 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.
* - Neither the name of the copyright holders 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/

#include "RadioCountToLeds.h"

/**
* Configuration for the RadioCountToLeds application. RadioCountToLeds
* maintains a 4Hz counter, broadcasting its value in an AM packet
* every time it gets updated. A RadioCountToLeds node that hears a counter
* displays the bottom three bits on its LEDs. This application is a useful
* test to show that basic AM communication and timers work.
*
* @author Philip Levis
* @date June 6 2005
*/

configuration RadioCountToLedsAppC {}
implementation {
components MainC, RadioCountToLedsC as App, LedsC, NoLedsC;
//components new SecAMSenderC(AM_RADIO_COUNT_MSG) as AMSenderC;
components new AMSenderC(AM_RADIO_COUNT_MSG);
components new AMReceiverC(AM_RADIO_COUNT_MSG);
components new TimerMilliC();
components CC2520KeyC;
components ActiveMessageC;

App.Boot -> MainC.Boot;
App.Receive -> AMReceiverC;
App.AMSend -> AMSenderC;
App.AMControl -> ActiveMessageC;
App.Leds -> LedsC;
App.MilliTimer -> TimerMilliC;
App.Packet -> AMSenderC;
App.CC2520Key -> CC2520KeyC;

components new TimerMilliC() as SendTimer;
App.SendTimer -> SendTimer;

components CC2520ActiveMessageC as Radio;
App.PacketLink -> Radio;

components CC2520PacketC;
App.CC2520PacketBody -> CC2520PacketC;

components PrintfC,SerialStartC;
}
218 changes: 218 additions & 0 deletions apps/RadioCountToLeds1/RadioCountToLedsC.nc
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
/*
* Copyright (c) 2000-2005 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - 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.
* - Neither the name of the copyright holders 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/

#include "Timer.h"
#include "RadioCountToLeds.h"
#include "printf.h"
/**
* Implementation of the RadioCountToLeds application. RadioCountToLeds
* maintains a 4Hz counter, broadcasting its value in an AM packet
* every time it gets updated. A RadioCountToLeds node that hears a counter
* displays the bottom three bits on its LEDs. This application is a useful
* test to show that basic AM communication and timers work.
*
* @author Philip Levis
* @date June 6 2005
*/

module RadioCountToLedsC {
uses {
interface Leds;
interface Boot;
interface Receive;
interface AMSend;
interface Timer<TMilli> as MilliTimer;
interface Timer<TMilli> as SendTimer;
interface SplitControl as AMControl;
interface Packet;
interface CC2520Key;
interface CC2520PacketBody;

interface PacketLink;
}
}
implementation {

message_t packet;
uint8_t key[16] = {0x98,0x67,0x7F,0xAF,0xD6,0xAD,0xB7,0x0C,0x59,0xE8,0xD9,0x47,0xC9,0x71,0x15,0x0F};
uint8_t keyReady = 0; // should be set to 1 when key setting is done

bool locked;
uint16_t counter = 0;

event void Boot.booted()
{
call AMControl.start();
}

event void AMControl.startDone(error_t err)
{
if (err == SUCCESS) {
call CC2520Key.setKey(key);
// if(TOS_NODE_ID == 1)
//call MilliTimer.startPeriodic(4096);
} else {
call AMControl.start();
}
}

event void AMControl.stopDone(error_t err)
{
}
event void CC2520Key.setKeyDone(uint8_t status)
{
keyReady = 1;
}

event void CC2520Key.getKeyDone(uint8_t status, uint8_t *ptr)
{
}

event void SendTimer.fired()
{
if (call AMSend.send(AM_BROADCAST_ADDR, &packet,
sizeof(radio_count_msg_t)) == SUCCESS) {
locked = TRUE;
//printf("SendTimer fired\n");
//printfflush();
}


}

uint8_t getMICLength(uint8_t securityLevel) {
if(securityLevel == SEC_MIC_32 || securityLevel == SEC_ENC_MIC_32)
return 4;
else if(securityLevel == SEC_MIC_64 || securityLevel == SEC_ENC_MIC_64)
return 8;
else if(securityLevel == SEC_ENC_MIC_128 || securityLevel == SEC_ENC_MIC_128)
return 16;
return 0;
}

void readBefore()
{
uint8_t i;
cc2520_header_t* header = call CC2520PacketBody.getHeader( &packet );
uint8_t *ptr = (uint8_t *)header;
uint8_t micLength = getMICLength(header->secHdr.secLevel);
uint8_t encryptLength = header->length - CC2520_SIZE - micLength;
printf("Packet Before Encryption\n");
printf("header Length:%x\n", header->length);
printf("MIC Length:%x\t%x\n",micLength,encryptLength);
for(i=0;i<header->length - micLength -1;i++) {
printf("%x\t",ptr[i]);
}
printfflush();
}

event void MilliTimer.fired()
{
int ret;
counter++;
//printf("MilliTimer fired\n");
//printfflush();
dbg("RadioCountToLedsC", "RadioCountToLedsC: timer fired, counter is %hu.\n", counter);
if (locked) {
return;
}
else if(keyReady == 1) {

radio_count_msg_t* rcm = (radio_count_msg_t*)call Packet.getPayload(&packet, sizeof(radio_count_msg_t));

if (rcm == NULL) {
return;
}

rcm->counter = counter;
//call CC2420Security.setCtr(&packet, 0, 0);
//call CC2420Security.setCbcMac(&packet, 0, 0, 16);
//call CC2420Security.setCcm(&packet, 1, 0, 16);
call PacketLink.setRetries(&packet, 1);
//call SendTimer.startOneShot(5000);
//readBefore();
ret= call AMSend.send(AM_BROADCAST_ADDR, &packet,
sizeof(radio_count_msg_t));
printf("return:%x\n",ret);
printfflush();
}
}

event message_t* Receive.receive(message_t* bufPtr,
void* payload, uint8_t len)
{
dbg("RadioCountToLedsC", "Received packet of length %hhu.\n", len);
if (len != sizeof(radio_count_msg_t)) {return bufPtr;}
else {
radio_count_msg_t* rcm = (radio_count_msg_t*)payload;
printf("counter:%x\n",rcm->counter);
printfflush();
if (rcm->counter & 0x1) {
call Leds.led0On();
}
else {
call Leds.led0Off();
}
if (rcm->counter & 0x2) {
call Leds.led1On();
}
else {
call Leds.led1Off();
}
if (rcm->counter & 0x4) {
call Leds.led2On();
}
else {
call Leds.led2Off();
}
return bufPtr;
}
}

event void AMSend.sendDone(message_t* msg, error_t error)
{
printf("AMSend sendDone:%x\n",error);
printfflush();
if (&packet == msg) {
locked = FALSE;
}
}

}
7 changes: 3 additions & 4 deletions apps/tests/TestPrintf/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
COMPONENT=TestPrintfAppC
CFLAGS += -I$(TINYOS_OS_DIR)/lib/printf

TINYOS_ROOT_DIR?=../../..
include $(TINYOS_ROOT_DIR)/Makefile.include
CFLAGS += -I$(TOSDIR)/lib/printf
CFLAGS += -DDEFAULT_LOG_LEVEL=3
include $(MAKERULES)
Loading