https://toitlang.org/ logo
Jag run -d host with Bluetooth scan never times ou...
# help
z
Running this code on MacOS, the BLE Central scan never times out. It's not respecting the scan duration param?
Copy code
jag run -d host sample.toit
Copy code
SCAN_DURATION   ::= Duration --ms=250
find_by_name central/ble.Central name/string:
  central.scan --duration=SCAN_DURATION: | device/ble.RemoteScannedDevice |
    if device.data.name and device.data.name.contains name:
        return device.address
  throw "no ring device found"
Yeah, even following something like the ble example from https://github.com/toitlang/toit/blob/master/examples/ble/scan.toit just results in a hanging process that never times out
Copy code
// Copyright (C) 2023 Toitware ApS.
// Use of this source code is governed by a Zero-Clause BSD license that can
// be found in the examples/LICENSE file.

import ble
SCAN-DURATION   ::= Duration --s=3

main:
  adapter := ble.Adapter
  central := adapter.central

  addresses := []

  central.scan --duration=SCAN-DURATION: | device/ble.RemoteScannedDevice |
      addresses.add device.address

  print addresses
(I opened https://github.com/toitlang/toit/issues/2512) . Is there a way to downgrade the SDK
f
The easiest is probably to just download the binary. But we are looking into it.
z
Trying it on a different workstation, I notice that I get a log line:
cm started
that I don't get on the problem workstation
that's
Copy code
Version:         v1.33.0
SDK version:     v2.0.0-alpha.145
Build date:      2024-04-22T20:36:07Z
k
I believe we found and fixed the issue. Will send out new versions of Jaguar and Artemis with the fix early next week. Thanks for reporting this!
z
thanks!!
f
Let me check, but very likely.
Yes: Toit SDK v2.0.0-alpha.160 (part of jag 1.41.0) has the BLE fix: https://github.com/toitlang/toit/releases/tag/v2.0.0-alpha.160
z
excellent! got it all updated