Bsr à vous,
Je me familiarise avec la librairie SimpleBLE et le projet InsideBlue fonctionne sans problème: BT_Bric4_dvp.zip
J'ai créé un projet de test (PiloteBRIC4) pour un objet TBRIC4 qui gère la connexion BLE
Découverte du BT LE: OK
Init BLE: OK
Au droit du SimpleBleAdapterScanStart et SimpleBleAdapterScanStop: AV
Je suis sous Linux Mint 21 64 bits, Lazarus 2.2.0 et FPC 3.3.2 amd64 bits
Dans le OnTimer de TBRIC4:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 procedure TBRIC4.StartDiscoveryDevices(); var ERR: TSimpleBleErr; begin AfficherMessageErreur('%s.StartDiscoveryDevices(): 0x%X', [classname, BleAdapter]); AfficherMessageErreur('000'); if (not FlagBleScanningActive) then begin AfficherMessageErreur('FA: 001'); FlagBleScanningActive := true; AfficherMessageErreur('FI: 002'); FTimer.OnTimer := @self.ScanTimer; FTimer.Enabled := True; AfficherMessageErreur('Devices found: %d', [PeripheralNofDevices]); AfficherMessageErreur('FA: 003'); // OK SimpleBleAdapterScanStart(BleAdapter); // <--- AV ici AfficherMessageErreur('FA: 004'); end else begin AfficherMessageErreur('FI: 001'); FlagBleScanningActive := false; AfficherMessageErreur('FI: 002'); FTimer.OnTimer := nil; // @self.ScanTimer; AfficherMessageErreur('FI: 003'); SimpleBleAdapterScanStop(BleAdapter); AfficherMessageErreur('FI: 004'); end; end;
Inexplicable et irritant +++
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 procedure TBRIC4.ScanTimer(Sender: TObject); begin if (FTimer.Enabled) then begin AfficherMessageErreur('%s.ScanTimer()', [ClassName]); //exit; // check if BLE adapter is still enabled if SimpleBleAdapterIsBluetoothEnabled() <> BleIsEnabled then begin BleIsEnabled := SimpleBleAdapterIsBluetoothEnabled(); if (not BleIsEnabled) then begin AfficherMessageErreur('Bluetooth is disabled.'); FlagBleScanningActive := false; ScanClearPeripheralList; Exit; end else begin AfficherMessageErreur('Bluetooth is enabled.'); FlagBleScanningActive := false; SimpleBleAdapterScanStop(BleAdapter); Exit; end; end; // if SimpleBleAdapterIsBluetoothEnabled() <> BleIsEnabled then begin if (FlagBleScanningActive and (PeripheralNofDevices > 0)) then begin AfficherMessageErreur('Devices found %d: ', [PeripheralNofDevices]); end; end; // if (FTimer.Enabled) then end;
Partager