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

Guys,

 

I'm looking for a way to be able to add bricklets without coding for each one individually. For example i want to add a database row in a table that allows me to put in the bricklet info and have the value updated in that row. Currently i have to add a callback in the code for each sensor which is a pain when i want to add more sensors.

 

Is there an easy way to do this so that the sensor network can be expanded without changing the code in the application?

Geschrieben

Use the enumeration callback of the IPConnection.

 

2.0 example:

    public void main(...)
    {
        //...
        ipcon.Enumerate += EnumerateCB;
    }

    static void EnumerateCB(IPConnection sender,
                            string uid, string connectedUid, char position,
                            short[] hardwareVersion, short[] firmwareVersion,
                            int deviceIdentifier, short enumerationType)
    {
        if(enumerationType == IPConnection.ENUMERATION_TYPE_DISCONNECTED)
        {
           return; //we don't care for disconnected devices
        }
        if(deviceIdentifier == 216)  //Temperature-Bricklet, as of http://www.tinkerforge.com/doc/Software/Device_Identifier.html#device-identifier
        {
           var bricklet = new BrickletTemperature(uid, sender);
           bricklet.SetTemperatureCallbackPeriod(100);
           bricklet.Temperature += TemperatureCB;
        }
    }

    private static void TemperatureReached(BrickletTemperature sender, short temperature)
    {
        //update your database with sender.uid and temperature
    }

 

This example contains mostly code from my mind, so there might be typos.

Also: I saw that there is no Accessor for the UID on the Device-class. So my comment about "use sender.UID" is wrong, but I think this needs to be changed :D (Pull Request in preparation ^^)

Geschrieben
  • Autor

OK, i have got this to work using

static void Temp1CB(BrickletTemperature sender, short temperature)
        {
            string uid;
            string connecteduid;
            char position;
            byte[] hardwareversion;
            byte[] firmwareversion;
            int deviceidentifier;
            sender.GetIdentity(out uid,out connecteduid,out position,out hardwareversion,out firmwareversion,out deviceidentifier);
            
         //code to update database with uid and temperature
        }

 

Is there simpler way to get the uid without all the other information? As you pointed out there doesn't seem to be a sender.uid

 

Thanks for the quick help!

Geschrieben
  • Autor

Ok, In about 2 simple changes to my code i now have this working perfectly!

 

Thanks again for the quick reply!

  • 2 weeks later...
Geschrieben

The latest C# Bindings should include an accessor for the UID ;)

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.