Jump to content
View in the app

A better way to browse. Learn more.

Tinkerunity

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Geschrieben

Hallo,

 

ich bastel gerade an einem Stack mit mehreren IO16 Bricklets. Dabei ist aufgefallen, dass anderes als bei IPConnection

 

void IPConnection::registerCallback(int $id, callable $callback, mixed $userData=NULL)

 

kein 3. Argument "mixed $userData=NULL" zu Verfügung steht.

Stattdessen wird nur

 

void BrickletIO16::registerCallback(int $id, callable $callback)

 

angeboten. Dies führt nun zu einem ziemlich hässlichen Konstrukt um eine Lösung dafür zu schaffen.

 

function cb_io1($p,$i,$v) { cb_interrupt($p,$i,$v,'io1'); }
function cb_io2($p,$i,$v) { cb_interrupt($p,$i,$v,'io2'); }
function cb_io3($p,$i,$v) { cb_interrupt($p,$i,$v,'io3'); }
function cb_io4($p,$i,$v) { cb_interrupt($p,$i,$v,'io4'); }
...
$io1->registerCallback(BrickletIO16::CALLBACK_INTERRUPT, 'cb_io1');
$io2->registerCallback(BrickletIO16::CALLBACK_INTERRUPT, 'cb_io2');
$io3->registerCallback(BrickletIO16::CALLBACK_INTERRUPT, 'cb_io3');
...

 

könntet ihr bitte in den PHP Bindings (ggf. auch in anderen wenn notwendig) das 3. Argument $userData einfügen? Generell denke ich mach es Sinn, dies bei allen registerCallBack einzufügen.

 

Alternativ wäre es hilfreich wenn der CallBack Aufruf die UID des Auslösenden Bricklets mitliefert. Andernfalls weis man zwar das A1 einen Interrupt ausgelöst hat, aber nicht von welchem Bricklet das ganze kommt.

 

Vielen Dank

 

Grüße

Martin

 

Geschrieben

Die dokumentierte und implementierte Signatur ist schon diese:

 

void BrickletIO16::registerCallback(int $id, callable $callback, mixed $userData=NULL)

 

Allerdings fehlte beim Aufruf des eigentlichen Callbacks die Übergabe des $userData Parameters, so dass bei deiner cb_io1 Funktion dann kein $userData Parameter ankommt. Das ist jetzt korrigiert.

 

Angehängt die korrigierte Version zum Testen.

tinkerforge_php_bindings_2_0_13_rc1.zip

Geschrieben
  • Autor

Hallo,

 

danke. Mit der tinkerforge_php_bindings_2_0_13_rc1.zip klappt der Callback auch mit UserData.

 

Grüße

Martin

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Reply to this topic...

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.