close
ble.Adapter.close
ble.Adapter.central.close
/Users/fred/.cache/jaguar/sdk/bin/toit.run: Segmentation fault: 11
0: run-program <pkg:pkg-host>/pipe.toit:491:5
1: run /Users/runner/work/toit/toit/tools/toit.toit:529:10
2: compile-or-analyze-or-run /Users/runner/work/toit/toit/tools/toit.toit:618:16
3: main.<lambda> /Users/runner/work/toit/toit/tools/toit.toit:112:16
4: Command.run.<block> <pkg:pkg-cli>/cli.toit:308:40
5: Parser_.parse <pkg:pkg-cli>/parser_.toit:212:5
6: Command.run <pkg:pkg-cli>/cli.toit:306:12
7: main /Users/runner/work/toit/toit/tools/toit.toit:514:16
Error: exit status 1
(venv) ?1 o2r % jag version
Version: v1.45.1
SDK version: v2.0.0-alpha.170
Build date: 2024-11-29T20:49:14Z
close
ble.Adapter.close
import ble
DEV_NAME ::= "MR"
SCAN_DURATION ::= Duration --s=25
MONITOR_SERVICE ::= ble.BleUuid "f86afee0-8b6a-11e9-b0eb-80a589e0081a"
MONITOR_WRITE ::= ble.BleUuid "f86afee1-8b6a-11e9-b0eb-80a589e0081a"
MONITOR_NOTIFY ::= ble.BleUuid "f86afee2-8b6a-11e9-b0eb-80a589e0081a"
TOKEN_READ ::= ble.BleUuid "f86afee3-8b6a-11e9-b0eb-80a589e0081a"
find_by_name central/ble.Central name/string:
central.scan --duration=SCAN_DURATION: | device/ble.RemoteScannedDevice |
if device.identifier and device.data.name == name:
return device.identifier
throw "no ring device found"
class Ring:
adapter/ble.Adapter := ble.Adapter
token_read/ble.RemoteCharacteristic := ?
monitor_write/ble.RemoteCharacteristic := ?
monitor_notify/ble.RemoteCharacteristic := ?
constructor:
central := adapter.central
identifier := find_by_name central DEV_NAME
remote_device := central.connect identifier
print "Address: $remote_device.identifier"
services := remote_device.discover_services [MONITOR_SERVICE]
monitor_service/ble.RemoteService := services.first
ppg_service/ble.RemoteService := services.last
monitor_characteristics := monitor_service.discover_characteristics [TOKEN_READ, MONITOR_WRITE, MONITOR_NOTIFY]
token_read = monitor_characteristics[0]
monitor_write = monitor_characteristics[1]
monitor_notify = monitor_characteristics[2]
monitor_write.subscribe
monitor_notify.subscribe
main:
c := Ring
sleep --ms=2000
c.adapter.close
c.adapter.central.close
jag run -d host circul_kasper.toit
Address: 2ACB5B5E-2DC4-C265-1F05-19C40487DFC8
EXCEPTION error.
/Users/fred/.cache/jaguar/sdk/bin/toit.run: Segmentation fault: 11
0: run-program <pkg:pkg-host>/pipe.toit:491:5
1: run /Users/runner/work/toit/toit/tools/toit.toit:529:10
2: compile-or-analyze-or-run /Users/runner/work/toit/toit/tools/toit.toit:618:16
3: main.<lambda> /Users/runner/work/toit/toit/tools/toit.toit:112:16
4: Command.run.<block> <pkg:pkg-cli>/cli.toit:308:40
5: Parser_.parse <pkg:pkg-cli>/parser_.toit:212:5
6: Command.run <pkg:pkg-cli>/cli.toit:306:12
7: main /Users/runner/work/toit/toit/tools/toit.toit:514:16
Error: exit status 1