- task void GetChannelStateTask() {
- atomic {
- if((state != IDLE) && (state != CCA)) {
- post GetChannelStateTask();
- } else {
- state = CCA;
- rssiRead();
- //if(call RssiAdcResource.request() != SUCCESS) signalFailure();
- }
- }
- }
-
- void addSample() {
- if(rssiindex < NSAMPLES) rssisamples[rssiindex++] = rssi;
- deadlockCounter = 0;
- if(rssiindex >= NSAMPLES) post UpdateNoiseFloorTask();
- }
-
-
- void channelBusy () {
- atomic {
- if(++deadlockCounter >= DEADLOCK) addSample();
- state = IDLE;
- }
- signal ChannelMonitor.channelBusy();
- }
-
- void channelIdle() {
- atomic {
- addSample();
- state = IDLE;
- }
- signal ChannelMonitor.channelIdle();
- }
-
- error_t ccaCheckValue() {
- uint16_t data;
- atomic data = rssi;
- if(data < noisefloor + busyDelta) {
- channelIdle();
- } else {
- channelBusy();
- }
- return SUCCESS;
- }
-