Changing Broadcast parameters on event

I try to change broadcast signals on triggering of an event. It works ~50% of the cases immediately. Sometimes it's delayed for minutes, sometimes it changes device name but then changes back after a while again. I have a led flashing also on the same event to confirm the event was triggered. Also I have a macro that changes back the name at board disconnect and that macros runs all the time with an immediate change of broadcast name.. Have 3 different devices with android 4.4.1 and 5.1.1 that I listen with. Tested with Firmware 1.1.2 and 1.1.3


accelModule.routeData().fromAxes().split()
                .branch().log(ACCEL_DATA)
                .branch().process(new Rms()).process(new Comparison(Comparison.Operation.GT, 1)).stream("alarm")
.monitor(new DataSignal.ActivityHandler() {
                             @Override
                             public void onSignalActive(Map<String, DataProcessor> map, DataSignal.DataToken dataToken) {
                                 settingsModule.configure().setDeviceName(ALARM)
                                         .setAdInterval((short) 500, (byte) 0)
                                         .setTxPower((byte) 4)
                                         .commit();


                                     ledModule.configureColorChannel(Led.ColorChannel.BLUE)
                                             .setRiseTime((short) 0)
                                             .setPulseDuration((short) 1000).setRepeatCount((byte) 1)
                                             .setHighTime((short) 500).setHighIntensity((byte) 16)
                                             .setLowIntensity((byte) 16).commit();
                                     ledModule.play(false);
                             }

Comments

  • edited March 2016
    Hello do you have a working example ?

    I'd like to set the minor/major iBeacon value according to Accelerator axis (for my MetaDice)

    accelModule.routeData().fromAxes().monitor(new DataSignal.ActivityHandler() {
    @Override
    public void onSignalActive(Map<String, DataProcessor> processors, DataSignal.DataToken token) {
    ibeaconModule.configure().setMinor((short) Math.round(Math.random() * 10)).commit();
    ledModule.play(true);
    }
    }).commit();

    The LED is set to blue even if the board is offline but the Minor value seems to be set only once

    Thanks
  • The ActivityHandler is for executing MetaWear commands.  Your random number will be selected when the commands are being programmed to the board so it won't change after the first event.  If you need dynamic minor/major numbers, I will have to extend the IBeacon class to use DataTokens.
  • Hum ok understood it was too magic :-)
    Indeed it would be interesting to be able to bring some logic on board. 

    For Instance:
    if (X < -0.8) then minor = 1
    if (Y < -0.8) then minor = 2

    But it seems very complicated, where is the limit ? Logic code can be complexe. Does the MetaWare board have a kind of runtime like the eval(...) in JavaScript ?

    On the other hand, I uderstand to much logic code will kill processing performance

    Using DataProcessor for all the logic, for each axes is a challenge because it could be a lots of pipe
  • What do you mean by "lots of pipe?".  You would only need 6 comparators (2 for each axis).
This discussion has been closed.