Skip to content

Commit

Permalink
fix(ble): add a retry on start ble for darwin
Browse files Browse the repository at this point in the history
Signed-off-by: Sacha Froment <sfroment42@gmail.com>
  • Loading branch information
sfroment committed Jan 2, 2019
1 parent 9564064 commit 649f22b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion core/network/ble/darwin.go
Expand Up @@ -138,11 +138,16 @@ func waitForOn() int {
func NewListener(lAddr ma.Multiaddr, hostID peer.ID, t *Transport) (*Listener, error) {
C.init()

for res := waitForOn(); res == 1; res = waitForOn() {
i := 0
for res := waitForOn(); res != 1; res = waitForOn() {
if res == -1 {
return nil, fmt.Errorf("error ble not supported")
}
logger().Debug("Ble centralManager or peripheralManager isn't on wait 1sec and retry")
i++
if i == 5 {
return nil, fmt.Errorf("error ble not activated")
}
time.Sleep(1 * time.Second)
}

Expand Down

0 comments on commit 649f22b

Please sign in to comment.