Skip to content

Commit

Permalink
Added checkbox in vsp terminal to select write command vs. write requ…
Browse files Browse the repository at this point in the history
…est (if exposed by peripheral).

Changed version to 0.6.1
Updated help file, CHANGELOG.md and README.md
  • Loading branch information
eriklins committed Mar 28, 2023
1 parent 746319e commit e260515
Show file tree
Hide file tree
Showing 7 changed files with 336 additions and 183 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)



## [Unreleased]
## [0.6.1] - 2023-03-28

### Added

- Updated simpleble.pas with SimpleBleGetVersion().
- Added output of SimpleBLE version to log on start.
- Added checkbox in vsp terminal to select write command vs. write request (if exposed by peripheral).

### Changed

Expand All @@ -18,7 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Fixed

- Reduced flickering in VSP terminal when receiving large chunks of data.
- Fixed bug when searching VSP which is also an assigned service (didn't show vsp terminal button).
- Fixed bug when searching VSP service which is also an assigned service (didn't show vsp terminal button).

### Removed

Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# InsideBlue BLE Tool V0.6
# InsideBlue BLE Tool V0.6.1
Welcome to **InsideBlue BLE Tool**, an easy to use cross-platform application for Bluetooth Low-Energy (BLE) connectivity leveraging the PC’s integrated Bluetooth adapter.

You can scan for BLE devices that are advertising and discover their GAP services or manufacturer specific data, engage a connection and access the peripheral GATT table.
Expand Down Expand Up @@ -65,6 +65,9 @@ Beside the mandatory TX (from peripheral to central) and RX (from central to per
### Length of RX Characteristic
The length of the peripheral RX characteristic is not known to the central, hence when sending text lines with too many characters, the BLE write operation will fail.

### WriteCommand/WriteRequest
Depending on the write properties of the RX characteristic you can select to use write request or write command, if both are exposed.

## Pairing Devices
On operating systems, initiating a connection procedure will automatically run pairing if necessary. This process is entirely managed by the operating system, there isn't much that we can do from the user side.

Expand Down
31 changes: 23 additions & 8 deletions src/connect.pas
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ TCharDescData = record

{ Device data we need during an active device connection }
TBleConnectData = record
ScnIdx: integer;
ScnIdx: integer;
PeripheralHandle: TSimpleBlePeripheral;
DeviceName: String;
MacAddress: String;
Expand All @@ -83,6 +83,8 @@ TBleConnectData = record
IsConnected: Boolean;
IsPaired: Boolean;
HasVspService: Boolean;
HasVspWriteCmd: Boolean;
HasVspWriteReq: Boolean;
NotIndActiveCnt: array of Integer;
AttMtuSize: Integer;
end;
Expand Down Expand Up @@ -168,6 +170,7 @@ procedure ConnectDevice(DevName: string; MacAddr: string; PerHandle: TSimpleBleP
Buffer: array of Byte;
ChData: PByte;
ChLen: NativeUInt;
FlagVspChar: Boolean;
begin
SetLength(Buffer, CharDescMaxLength);
ChData := PByte(Buffer);
Expand Down Expand Up @@ -300,7 +303,6 @@ procedure ConnectDevice(DevName: string; MacAddr: string; PerHandle: TSimpleBleP
DeviceFormElements[i].LabelServiceUuid[SvIdx].Hint := s;
end;
if BleConnectData[i].HasVspService then begin
UtilLog('HasVspService');
DeviceFormElements[i].ButtonVspTerminal[SvIdx] := TButton.Create(DeviceForm[i]);
DeviceFormElements[i].ButtonVspTerminal[SvIdx].Parent := DeviceFormElements[i].Panel[SvIdx];
DeviceFormElements[i].ButtonVspTerminal[SvIdx].Tag := (i shl TagPosDev) or (SvIdx shl TagPosSrv);
Expand All @@ -325,15 +327,18 @@ procedure ConnectDevice(DevName: string; MacAddr: string; PerHandle: TSimpleBleP
for ChIdx := 0 to BleConnectData[i].Services[SvIdx].CharacteristicCount-1 do begin
SetLength(BleConnectData[i].Characteristic[SvIdx][ChIdx].data, CharDescMaxLength);
SetString(s, BleConnectData[i].Services[SvIdx].Characteristics[ChIdx].Uuid.Value, SIMPLEBLE_UUID_STR_LEN-1);
n := BleAssignedCharacteristicUuidToName(BleConnectData[i].Services[SvIdx].Characteristics[ChIdx].Uuid);
n := BleVspCharacteristicUuidToName(BleConnectData[i].Services[SvIdx].Characteristics[ChIdx].Uuid);
FlagVspChar := false;
if n = '' then begin
n := BleVspCharacteristicUuidToName(BleConnectData[i].Services[SvIdx].Characteristics[ChIdx].Uuid);
if n = '' then // neither assigned service nor vsp service
n := BleAssignedCharacteristicUuidToName(BleConnectData[i].Services[SvIdx].Characteristics[ChIdx].Uuid);
if n = '' then // neither assigned characteristic nor vsp characteristic
UtilLog(' CH: ' + s)
else // vsp service
else // assigned characteristic
UtilLog(' CH: ' + s + ' (' + n + ')');
end else // assigned service
end else begin // vsp characteristic
UtilLog(' CH: ' + s + ' (' + n + ')');
FlagVspChar := true;
end;

DeviceFormElements[i].LabelCharacteristicUuid[SvIdx][ChIdx] := TLabel.Create(DeviceForm[i]);
DeviceFormElements[i].LabelCharacteristicUuid[SvIdx][ChIdx].Parent := DeviceFormElements[i].Panel[SvIdx];
Expand Down Expand Up @@ -411,6 +416,8 @@ procedure ConnectDevice(DevName: string; MacAddr: string; PerHandle: TSimpleBleP
DeviceFormElements[i].ToggleBoxCharProp[SvIdx][ChIdx][CanWriteCommand].OnChange := @DeviceForm[i].ButtonCharWriteCommand;
NextButtonCoord := NextButtonCoord + 4*DeviceFormPaddingHorizontal + FormElementsExtraWidth + DeviceFormPropPadding;
DeviceFormElements[i].TextBoxCharacteristic[SvIdx][ChIdx].OnEditingDone := @DeviceForm[i].CharEditingDone;
if FlagVspChar then
BleConnectData[i].HasVspWriteCmd := True;
end;
if BleConnectData[i].Services[SvIdx].Characteristics[ChIdx].CanWriteRequest then begin
DeviceFormElements[i].TextBoxCharacteristic[SvIdx][ChIdx].ReadOnly := false;
Expand All @@ -426,6 +433,8 @@ procedure ConnectDevice(DevName: string; MacAddr: string; PerHandle: TSimpleBleP
DeviceFormElements[i].ToggleBoxCharProp[SvIdx][ChIdx][CanWriteRequest].OnChange := @DeviceForm[i].ButtonCharWriteRequest;
NextButtonCoord := NextButtonCoord + 4*DeviceFormPaddingHorizontal + FormElementsExtraWidth + DeviceFormPropPadding;
DeviceFormElements[i].TextBoxCharacteristic[SvIdx][ChIdx].OnEditingDone := @DeviceForm[i].CharEditingDone;
if FlagVspChar then
BleConnectData[i].HasVspWriteReq := True;
end;
if BleConnectData[i].Services[SvIdx].Characteristics[ChIdx].CanNotify then begin
DeviceFormElements[i].ToggleBoxCharProp[SvIdx][ChIdx][CanNotify] := TToggleBox.Create(DeviceForm[i]);
Expand Down Expand Up @@ -586,7 +595,13 @@ procedure TDeviceForm.ButtonVspTerminalClick(Sender: TObject);

DeviceFormElements[DeIdx].Panel[SvIdx].Enabled := false;

UartTerminalStart(BleConnectData[DeIdx].PeripheralHandle, BleConnectData[DeIdx].DeviceName, BleConnectData[DeIdx].MacAddress, BleConnectData[DeIdx].Services[SvIdx].Uuid, DeviceFormElements[DeIdx].Panel[SvIdx]);
UartTerminalStart(BleConnectData[DeIdx].PeripheralHandle,
BleConnectData[DeIdx].DeviceName,
BleConnectData[DeIdx].MacAddress,
BleConnectData[DeIdx].Services[SvIdx].Uuid,
BleConnectData[DeIdx].HasVspWriteCmd,
BleConnectData[DeIdx].HasVspWriteReq,
DeviceFormElements[DeIdx].Panel[SvIdx]);
end;


Expand Down
Loading

0 comments on commit e260515

Please sign in to comment.