Skip to content

Commit

Permalink
generic NeighborhoodC (for multiple independent rfxlink) - resolves t…
Browse files Browse the repository at this point in the history
  • Loading branch information
andrasbiro committed Mar 24, 2015
1 parent 726bb95 commit 8bb461d
Show file tree
Hide file tree
Showing 43 changed files with 183 additions and 2,323 deletions.
1 change: 0 additions & 1 deletion support/make/platforms/ucprotonb.platform
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
PFLAGS += -I%T/platforms/ucprotonb
PFLAGS += -I%T/platforms/ucprotonb/chips/stm25p
PFLAGS += -I%T/platforms/ucprotonb/chips/rf212
#PFLAGS += -I%T/platforms/ucprotonb/chips/doubleradio
PFLAGS += -I%T/chips/atm128rfa1
PFLAGS += -I%T/chips/atm128rfa1/adc
PFLAGS += -I%T/chips/atm128rfa1/pins
Expand Down
10 changes: 9 additions & 1 deletion tos/chips/atm128rfa1/radio/RFA1RadioC.nc
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,16 @@ implementation
{
#define UQ_METADATA_FLAGS "UQ_RFA1_METADATA_FLAGS"
#define UQ_RADIO_ALARM "UQ_RFA1_RADIO_ALARM"
#define UQ_NEIGHBORHOOD_FLAG "UQ_RFA1_NEIGHBORHOOD_FLAG"

// -------- TaskleC

components new TaskletC();


// -------- NeighborhoodC

components new NeighborhoodC(RFA1_NEIGHBORHOOD_SIZE);


// -------- RadioP
Expand Down Expand Up @@ -218,9 +224,11 @@ implementation

// -------- UniqueLayer Send part (wired twice)

components new UniqueLayerC();
components new UniqueLayerC(RFA1_NEIGHBORHOOD_SIZE);
UniqueLayerC.Config -> RadioP;
UniqueLayerC.SubSend -> PacketLinkLayerC;
UniqueLayerC.Neighborhood -> NeighborhoodC;
UniqueLayerC.NeighborhoodFlag -> NeighborhoodC.NeighborhoodFlag[unique(UQ_NEIGHBORHOOD_FLAG)];

// -------- Packet Link

Expand Down
9 changes: 8 additions & 1 deletion tos/chips/cc2420x/CC2420XRadioC.nc
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,16 @@ implementation
{
#define UQ_METADATA_FLAGS "UQ_CC2420X_METADATA_FLAGS"
#define UQ_RADIO_ALARM "UQ_CC2420X_RADIO_ALARM"
#define UQ_NEIGHBORHOOD_FLAG "UQ_CC2420X_NEIGHBORHOOD_FLAG"

// -------- TaskleC

components new TaskletC();

// -------- NeighborhoodC

components new NeighborhoodC(CC2420X_NEIGHBORHOOD_SIZE);

// -------- RadioP

components CC2420XRadioP as RadioP;
Expand Down Expand Up @@ -172,9 +177,11 @@ implementation

// -------- UniqueLayer Send part (wired twice)

components new UniqueLayerC();
components new UniqueLayerC(CC2420X_NEIGHBORHOOD_SIZE);
UniqueLayerC.Config -> RadioP;
UniqueLayerC.SubSend -> PacketLinkLayerC;
UniqueLayerC.Neighborhood -> NeighborhoodC;
UniqueLayerC.NeighborhoodFlag -> NeighborhoodC.NeighborhoodFlag[unique(UQ_NEIGHBORHOOD_FLAG)];

// -------- Packet Link

Expand Down
10 changes: 9 additions & 1 deletion tos/chips/cc2520/CC2520RadioC.nc
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,16 @@ implementation
{
#define UQ_METADATA_FLAGS "UQ_CC2520_METADATA_FLAGS"
#define UQ_RADIO_ALARM "UQ_CC2520_RADIO_ALARM"
#define UQ_NEIGHBORHOOD_FLAG "UQ_CC2520_NEIGHBORHOOD_FLAG"

// -------- TaskleC

components new TaskletC();

// -------- NeighborhoodC

components new NeighborhoodC(CC2520_NEIGHBORHOOD_SIZE);

// -------- RadioP

components CC2520RadioP as RadioP;
Expand Down Expand Up @@ -186,9 +191,12 @@ implementation

// -------- UniqueLayer Send part (wired twice)

components new UniqueLayerC();
components new UniqueLayerC(CC2520_NEIGHBORHOOD_SIZE);
UniqueLayerC.Config -> RadioP;
UniqueLayerC.SubSend -> PacketLinkLayerC;
UniqueLayerC.Neighborhood -> NeighborhoodC;
UniqueLayerC.NeighborhoodFlag -> NeighborhoodC.NeighborhoodFlag[unique(UQ_NEIGHBORHOOD_FLAG)];


// -------- Packet Link

Expand Down
9 changes: 8 additions & 1 deletion tos/chips/rf212/RF212RadioC.nc
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,16 @@ implementation
{
#define UQ_METADATA_FLAGS "UQ_RF212_METADATA_FLAGS"
#define UQ_RADIO_ALARM "UQ_RF212_RADIO_ALARM"
#define UQ_NEIGHBORHOOD_FLAG "UQ_RF212_NEIGHBORHOOD_FLAG"

// -------- TaskleC

components new TaskletC();

// -------- NeighborhoodC

components new NeighborhoodC(RF212_NEIGHBORHOOD_SIZE);

// -------- RadioP

components RF212RadioP as RadioP;
Expand Down Expand Up @@ -183,9 +188,11 @@ implementation

// -------- UniqueLayer Send part (wired twice)

components new UniqueLayerC();
components new UniqueLayerC(RF212_NEIGHBORHOOD_SIZE);
UniqueLayerC.Config -> RadioP;
UniqueLayerC.SubSend -> PacketLinkLayerC;
UniqueLayerC.Neighborhood -> NeighborhoodC;
UniqueLayerC.NeighborhoodFlag -> NeighborhoodC.NeighborhoodFlag[unique(UQ_NEIGHBORHOOD_FLAG)];

// -------- Packet Link

Expand Down
10 changes: 9 additions & 1 deletion tos/chips/rf230/RF230RadioC.nc
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,16 @@ implementation
{
#define UQ_METADATA_FLAGS "UQ_RF230_METADATA_FLAGS"
#define UQ_RADIO_ALARM "UQ_RF230_RADIO_ALARM"
#define UQ_NEIGHBORHOOD_FLAG "UQ_RF230_NEIGHBORHOOD_FLAG"

// -------- TaskleC

components new TaskletC();

// -------- NeighborhoodC

components new NeighborhoodC(RF230_NEIGHBORHOOD_SIZE);

// -------- RadioP

components RF230RadioP as RadioP;
Expand Down Expand Up @@ -216,9 +221,12 @@ implementation

// -------- UniqueLayer Send part (wired twice)

components new UniqueLayerC();
components new UniqueLayerC(RF230_NEIGHBORHOOD_SIZE);
UniqueLayerC.Config -> RadioP;
UniqueLayerC.SubSend -> PacketLinkLayerC;
UniqueLayerC.Neighborhood -> NeighborhoodC;
UniqueLayerC.NeighborhoodFlag -> NeighborhoodC.NeighborhoodFlag[unique(UQ_NEIGHBORHOOD_FLAG)];


// -------- Packet Link

Expand Down
11 changes: 7 additions & 4 deletions tos/lib/rfxlink/layers/UniqueLayerC.nc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* Author: Miklos Maroti
*/

generic configuration UniqueLayerC()
generic configuration UniqueLayerC(uint8_t neigborhoodSize)
{
provides
{
Expand All @@ -46,16 +46,19 @@ generic configuration UniqueLayerC()
interface RadioReceive as SubReceive;

interface UniqueConfig as Config;

interface Neighborhood;
interface NeighborhoodFlag;
}
}

implementation
{
components new UniqueLayerP(), MainC, NeighborhoodC, new NeighborhoodFlagC();
components new UniqueLayerP(neigborhoodSize), MainC;

MainC.SoftwareInit -> UniqueLayerP;
UniqueLayerP.Neighborhood -> NeighborhoodC;
UniqueLayerP.NeighborhoodFlag -> NeighborhoodFlagC;
Neighborhood = UniqueLayerP.Neighborhood;
NeighborhoodFlag = UniqueLayerP.NeighborhoodFlag;

Send = UniqueLayerP;
SubSend = UniqueLayerP;
Expand Down
5 changes: 2 additions & 3 deletions tos/lib/rfxlink/layers/UniqueLayerP.nc
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@
*/

#include <Tasklet.h>
#include <Neighborhood.h>

generic module UniqueLayerP()
generic module UniqueLayerP(uint8_t neigborhoodSize)
{
provides
{
Expand Down Expand Up @@ -88,7 +87,7 @@ implementation
return signal RadioReceive.header(msg);
}

tasklet_norace uint8_t receivedNumbers[NEIGHBORHOOD_SIZE];
tasklet_norace uint8_t receivedNumbers[neigborhoodSize];

tasklet_async event message_t* SubReceive.receive(message_t* msg)
{
Expand Down
42 changes: 0 additions & 42 deletions tos/lib/rfxlink/util/Neighborhood.h

This file was deleted.

6 changes: 4 additions & 2 deletions tos/lib/rfxlink/util/NeighborhoodC.nc
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@
* Author: Miklos Maroti
*/

configuration NeighborhoodC
generic configuration NeighborhoodC(uint8_t size)
{
provides interface Neighborhood;
provides interface NeighborhoodFlag[uint8_t bit];
}

implementation
{
components NeighborhoodP, MainC;
components new NeighborhoodP(size), MainC;

Neighborhood = NeighborhoodP;
NeighborhoodFlag = NeighborhoodP;
MainC.SoftwareInit -> NeighborhoodP;
}
46 changes: 0 additions & 46 deletions tos/lib/rfxlink/util/NeighborhoodFlagC.nc

This file was deleted.

22 changes: 10 additions & 12 deletions tos/lib/rfxlink/util/NeighborhoodP.nc
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
* Author: Miklos Maroti
*/

#include <Neighborhood.h>

module NeighborhoodP
generic module NeighborhoodP(uint8_t size)
{
provides
{
Expand All @@ -46,17 +44,17 @@ module NeighborhoodP

implementation
{
tasklet_norace am_addr_t nodes[NEIGHBORHOOD_SIZE];
tasklet_norace uint8_t ages[NEIGHBORHOOD_SIZE];
tasklet_norace uint8_t flags[NEIGHBORHOOD_SIZE];
tasklet_norace am_addr_t nodes[size];
tasklet_norace uint8_t ages[size];
tasklet_norace uint8_t flags[size];
tasklet_norace uint8_t time;
tasklet_norace uint8_t last;

command error_t Init.init()
{
uint8_t i;

for(i = 0; i < NEIGHBORHOOD_SIZE; ++i)
for(i = 0; i < size; ++i)
nodes[i] = AM_BROADCAST_ADDR;

return SUCCESS;
Expand All @@ -79,7 +77,7 @@ implementation
if( nodes[last] == node )
return last;

for(i = 0; i < NEIGHBORHOOD_SIZE; ++i)
for(i = 0; i < size; ++i)
{
if( nodes[i] == node )
{
Expand Down Expand Up @@ -109,7 +107,7 @@ implementation
uint8_t oldest = 0;
maxAge = 0;

for(i = 0; i < NEIGHBORHOOD_SIZE; ++i)
for(i = 0; i < size; ++i)
{
uint8_t age;

Expand All @@ -132,7 +130,7 @@ implementation
}
}

if( i == NEIGHBORHOOD_SIZE )
if( i == size )
{
signal Neighborhood.evicted(oldest);

Expand All @@ -145,7 +143,7 @@ implementation

if( (time & 0x7F) == 0x7F && maxAge >= 0x7F )
{
for(i = 0; i < NEIGHBORHOOD_SIZE; ++i)
for(i = 0; i < size; ++i)
{
if( (ages[i] | 0x7F) != time )
ages[i] = time & 0x80;
Expand Down Expand Up @@ -176,7 +174,7 @@ implementation

bit = ~(1 << bit);

for(i = 0; i < NEIGHBORHOOD_SIZE; ++i)
for(i = 0; i < size; ++i)
flags[i] &= bit;
}
}
Loading

0 comments on commit 8bb461d

Please sign in to comment.