Skip to main content
. 2025 Aug 3;25(15):4773. doi: 10.3390/s25154773
Algorithm 2. Pseudocode for determining a coordinator.
while (the final winning master is not determined and T2 < T)
  If p > 0.5 in each master,
    the master is assigned to the scan mode
  else
    the master is assigned to the advertise mode
  end if
  if any two masters exchange information with each other
    Compare their neighbor list
    if the number of neighbors is equal
      The winner is the node with the smaller Bluetooth ID, and becomes as a master
    else the node with the most neighbors becomes the winning master
      The losing node becomes as slave, and will deliver its neighbor list to the winner.
      The losing nodes are removed until the final winning master is determined.
    end if
  end if
end while