[Tinyos-help] CCA Check in application layer.

Philip Levis pal at cs.stanford.edu
Thu Jul 17 11:17:16 PDT 2008


On Jul 17, 2008, at 10:25 AM, Hui Kang wrote:

> Dear All:
> In my tinyos-2.x application, I would like to check the channel before
> sending a packet. By copying the following code from  
> CC2420TransmitP.nc,
> I found the congest is always set as TRUE even I have only one mote  
> turn
> on. Could anyone help to solve this problem or any other smarter way  
> to
> check CCA? Thanks.
>
> uint8_t status;
> bool congestion = TRUE;
>
> atomic{
>            call CSN.clr();
>
>        status = call STXONCCA.strobe();
>        if ( !( status & CC2420_STATUS_TX_ACTIVE ) ) {
>            status = call SNOP.strobe();
>          if ( status & CC2420_STATUS_TX_ACTIVE ) {
>              congestion = FALSE;
>          }
>        }
>        call CSN.set();
> }
>
> - Hui
>

You can't just send commands over the SPI bus. You need to go through  
an arbiter and take a lock on the resource.

Phil


More information about the Tinyos-help mailing list