If you want to check the channel *before* sending a packet, you can sample the CCA pin directly. This GeneralIO is provided by HplCC2420PinsC.
The code you're looking at here actually sends a packet, if the channel is immediately found to be clear. If you're not doing so already, you must also acquire the SPI bus resource before sending commands over SPI. -David -----Original Message----- From: Hui Kang [mailto:[EMAIL PROTECTED] Sent: Thursday, July 17, 2008 10:26 AM To: David Moss Cc: tinyos-help@millennium.berkeley.edu Subject: CCA Check in application layer. 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 _______________________________________________ Tinyos-help mailing list Tinyos-help@millennium.berkeley.edu https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help