Permalink
Browse files

PJONSlave acquire_id_multimaster fix

  • Loading branch information...
gioblu committed Jan 27, 2018
1 parent 0188e8a commit 3443bc560f7fed8b23b97f33ea3b56b7ecc75795
Showing with 21 additions and 24 deletions.
  1. +21 −24 PJONSlave.h
@@ -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,

0 comments on commit 3443bc5

Please sign in to comment.