Trouble connecting BluetoothClient.Connect block to ListPicker.AfterPicking event

Hi everyone,
I’m having an issue with App Inventor: I can’t connect the purple BluetoothClient1.Connect block to the ListPickerConnect.AfterPicking event block.
As you can see in the image,


when I try to snap the Connect block inside the AfterPicking event, App Inventor shows the message:
“This block should be connected to an event block or a procedure definition”
but it still doesn’t allow me to attach it properly.
My goal is simply to connect to the selected Bluetooth device using:
call BluetoothClient1.Connect address ListPickerConnect.Selection
Does anyone know why this block won’t attach, or what I’m doing wrong?

Thanks in advance!

You need to use the connect block in an if/then/else block:

If Connect then
  (Set Connected Label.Text to "Connected")
Else
  (Set Connected Label.Text to "Not Connected")

Ciao Aldo, immagino tu sia Italiano !
Come ti ha detto già @ABG devi connettere il blocco magenta con un blocco di controllo oppure, visto che il blocco magenta restituisce un boolean, lo puoi assegnare ad una variabile booleana.
Ovvero:

oppure:

Delle due, ti suggerisco la prima, è la più usata.
Comunque se cerchi nel forum troverai una quantità "esagerata" :grin: di esempi.
Oppure nelle FAQ, gestite da @ABG o nei siti web di @ChrisWard (professordad.co.uk) o di @TIMAI2 (metricrat) o di @Taifun (puravidaapps). Se i problemi persistono, ti suggerisco anche di postare il tuo .ino e il tuo .aia, con un'indicazione dello schema HW del tuo sistema. Tieni inoltre presente che se il tuo sistema è un BT di tipo classico, sarà molto più facile farlo funzionare, mentre se è di tipo BLE dovrai caricare una estensione dedicata che trovi qui:
MIT App Inventor Extensions

Auguri e buon lavoro !!!

PS Se invece non sei Italiano, te lo riscrivo in inglese.... :hugs:

1 Like