guild icon
Toit
#AdvertisementData parameters
Thread channel in help
MichaelK
MichaelK 08/10/2026 11:22 AM
I found an inaccuracy in the ble.RemoteScannedDevice parameters when retrieving AdvertisementData.<manufacturer data>, as shown below:

micrcx@micrcx-desktop:~/toit/ruuvi_ble$ jag run -d basic ruuvi_ble.toit Scanning for device with name: 'basic' Running 'ruuvi_ble.toit' on 'basic' ... ruuvi_ble.toit:31:35: warning: Deprecated 'AdvertisementData.manufacturer-data'. Use 'Advertisement.manufacturer-specific' instead md/ByteArray := device.data.manufacturer-data ^~~~~~~~~~~~~~~~~ Success: Sent 78KB code to 'basic' in 2.92s
manufacturer-data was replaced with manufacturer-specific, but now a compilation error occurs:

micrcx@micrcx-desktop:~/toit/ruuvi_ble$ jag run -d basic ruuvi_ble.toit Scanning for device with name: 'basic' Running 'ruuvi_ble.toit' on 'basic' ... ruuvi_ble.toit:31:35: error: Argument mismatch for 'AdvertisementData.manufacturer-specific' Block argument not provided md/ByteArray := device.data.manufacturer-specific ^~~~~~~~~~~~~~~~~~~~~ Compilation failed
I've use Jaguar v1.69.0 with Toit SDK v2.0.0-alpha.196.
floitsch
floitsch 08/10/2026 11:26 AM
Can you show me a bit more of your code?
MichaelK
MichaelK 08/11/2026 06:43 AM
The code is below. The start-scan function is called from main. Let me know if this isn't enough. I can send you the full application.

start-scan : scan-task = task:: print "BLE device '$DEVICE_NAME' monitoring has started" adapter.central.scan : | device/ble.RemoteScannedDevice | md/ByteArray := device.data.manufacturer-data parseRuuvi md
Regards, Mk
MichaelKOPMichaelK
The code is below. The start-scan function is called from main. Let me know if this isn't enough. I can send you the full application. ``` start-scan : scan-task = task:: p...
floitsch
floitsch 08/11/2026 10:37 AM
manufacturer-specific now takes a block.
I haven't tested this, but I think you can just concatenate the company-id and data again:
md/ByteArray := device.data.manufacturer-specific: | company-id data | company-id + data // This is the result of the RHS expression.

If you only need the data, but not the company-id, you can just use that:
md/ByteArray := device.data.manufacturer-specific: | _ data | data // This is the result of the RHS expression.
(edited)
MichaelK
MichaelK 08/11/2026 11:05 AM
I probably described the situation incorrectly. I receive a vector of bytes and process it if I use the 'manufacturer-data' identifier. Everything is fine. The compiler simply issues a warning that the 'manufacturer-data' identifier is deprecated and that 'manufacturer-specific' should be used instead. But if I use 'manufacturer-specific', I get a message that this method doesn't exist at all. This is the same as if I decided to change the function name 'A' to 'B' in the code, but forgot to do so in the function definition itself. When calling the function, I wrote 'B(...)' instead of 'A(...)', Iwould get the exact same error.
floitsch
floitsch 08/11/2026 11:07 AM
My mistake. I meant to write manufacturer-specific. I updated my response
👍1
MichaelK
MichaelK 08/11/2026 11:40 AM
In general, everything works, but the logic needs to be slightly modified, as it's possible to get null-value when reading data:
start-scan : scan-task = task:: print "BLE device '$DEVICE_NAME' monitoring has started" adapter.central.scan : | device/ble.RemoteScannedDevice | md/ByteArray? := device.data.manufacturer-specific: | company-id data | company-id + data parseRuuvi md
And also need to process this possible null in the parseRuuvi function:
parseRuuvi md/ByteArray? -> none : if not md : return ... & etc
Thanks anyway.
7 messages in total