Skip to content

Commit

Permalink
PJONSlave acquire_id_multimaster fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gioblu committed Jan 27, 2018
1 parent 0188e8a commit 3443bc5
Showing 1 changed file with 21 additions and 24 deletions.
45 changes: 21 additions & 24 deletions PJONSlave.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,31 +103,28 @@ class PJONSlave : public PJON<Strategy> {
char msg = PJON_ID_ACQUIRE;
char head = this->config | required_config | PJON_ACK_REQ_BIT;
this->_device_id = PJON_NOT_ASSIGNED;
for(
uint8_t id;
((uint32_t)(PJON_MICROS() - time) < PJON_ID_SCAN_TIME);
) {
id = PJON_RANDOM(1, PJON_MAX_DEVICES);
if(
id == PJON_NOT_ASSIGNED ||
id == PJON_MASTER_ID ||
id == PJON_BROADCAST
) continue;
else if(
this->send_packet_blocking(
id,
this->bus_id,
&msg,
1,
head,
PJON_DYNAMIC_ADDRESSING_PORT
) == PJON_FAIL
) {
this->_device_id = id;
break;
}
}
uint8_t id = PJON_RANDOM(1, PJON_MAX_DEVICES);

if(
id == PJON_NOT_ASSIGNED ||
id == PJON_MASTER_ID ||
id == PJON_BROADCAST
) acquire_id_multi_master(limit);

if(
this->send_packet_blocking(
id,
this->bus_id,
&msg,
1,
head,
PJON_DYNAMIC_ADDRESSING_PORT
) == PJON_ACK
) acquire_id_multi_master(limit++);

this->_device_id = id;
receive(PJON_RANDOM(PJON_ACQUIRE_ID_DELAY) * 1000);

if(
this->send_packet_blocking(
this->_device_id,
Expand Down

0 comments on commit 3443bc5

Please sign in to comment.