added clear channel assessment timeout. long to begin with.
This commit is contained in:
parent
d8f6f03edc
commit
f0891be218
|
@ -24,14 +24,15 @@
|
|||
|
||||
#define CC_CONF_REGISTER_ARGS 1
|
||||
#define CC_CONF_FUNCTION_POINTER_ARGS 1
|
||||
|
||||
#define CC_CONF_INLINE inline
|
||||
|
||||
#define CC_CONF_VA_ARGS 1
|
||||
|
||||
#define CCIF
|
||||
#define CLIF
|
||||
|
||||
/* Clear channel assessment timeout for sending with the CC1020 radio. (ms) */
|
||||
#define CC1020_CONF_CCA_TIMEOUT 50
|
||||
|
||||
// Clock
|
||||
typedef unsigned short clock_time_t;
|
||||
#define CLOCK_CONF_SECOND 100
|
||||
|
|
|
@ -214,6 +214,8 @@ cc1020_set_power(uint8_t pa_power)
|
|||
int
|
||||
cc1020_send(const void *buf, unsigned short len)
|
||||
{
|
||||
int try;
|
||||
|
||||
if (cc1020_state == CC1020_OFF)
|
||||
return -2;
|
||||
|
||||
|
@ -237,7 +239,15 @@ cc1020_send(const void *buf, unsigned short len)
|
|||
|
||||
// Wait for the medium to become idle.
|
||||
if (cc1020_carrier_sense()) {
|
||||
while (cc1020_carrier_sense());
|
||||
for (try = 0; try < CC1020_CONF_CCA_TIMEOUT; try++) {
|
||||
MS_DELAY(1);
|
||||
if (!cc1020_carrier_sense()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (try == CC1020_CONF_CCA_TIMEOUT) {
|
||||
return -3;
|
||||
}
|
||||
|
||||
// Then wait for a short pseudo-random time before sending.
|
||||
clock_delay(100 * ((random_rand() + 1) & 0xf));
|
||||
|
|
Loading…
Reference in a new issue