The example code for BluetoothLowEnergey contains the following code:
function registerProfiles() { var profile = { // Set the Profile :uuid => Ble.stringToUuid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), :characteristics => [ { // Define the characteristics :uuid => Ble.stringToUuid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), // UUID of the first characteristic :descriptors => [ // Descriptors of the characteristic Ble.stringToUuid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), Ble.stringToUuid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") ] }, { :uuid => Ble.stringToUuid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") }] // UUID of the second characteristic }; // Make the registerProfile call BluetoothLowEnergy.registerProfile( profile ); }
But with CIQ SDK 4.1.5 the compiler throws the following error:
Invalid '$.Toybox.Lang.Dictionary{:characteristics as $.Toybox.Lang.Array<Any>, :uuid as $.Toybox.BluetoothLowEnergy.Uuid}' passed as parameter 1 of type '$.Toybox.Lang.Dictionary{:characteristics as $.Toybox.Lang.Array<{:uuid as $.Toybox.BluetoothLowEnergy.Uuid, :descriptors as $.Toybox.Lang.Array<$.Toybox.BluetoothLowEnergy.Uuid>}>, :uuid as $.Toybox.BluetoothLowEnergy.Uuid}'.
Adding Type-Annotations to the code:
typedef Ds as Lang.Array<Ble.Uuid>; typedef Cs as Lang.Array<{:uuid as Ble.Uuid, :descriptors as Ds}> var chars = [] as Cs chars.add({:uuid => ...}); chars.add({:uuid => ..., :descriptors => [ ... ]}); Ble.registerProfile({:uuid => ..., :characteristics => chars as Cs})
The error changes to
Invalid '$.Toybox.Lang.Dictionary{:characteristics as $.Toybox.Lang.Array<{:uuid as $.Toybox.BluetoothLowEnergy.Uuid, :descriptors as $.Toybox.Lang.Array<$.Toybox.BluetoothLowEnergy.Uuid>}>, :uuid as $.Toybox.BluetoothLowEnergy.Uuid}' passed as parameter 1 of type '$.Toybox.Lang.Dictionary{:characteristics as $.Toybox.Lang.Array<{:uuid as $.Toybox.BluetoothLowEnergy.Uuid, :descriptors as $.Toybox.Lang.Array<$.Toybox.BluetoothLowEnergy.Uuid>}>, :uuid as $.Toybox.BluetoothLowEnergy.Uuid}'.
Which is even stranger as I can't see the difference in the types...
So - how is one expected to use Ble with type checking on modern compiler?