Best Practice to monitor MetaWare

Hi,

I work on an IoT hub named SARAH since 3 years (working like Amazon Echo). The device is in the living room and remote control every IoT stuff with an API for Windows or NodeJS (150 plugins).

What would be the best Practice to listen MetaWare object ?

- Should I go very light listening for iBeacon to understand what's happened ? And so I should add data to the brodcast message.
- Should I try to stay connected to all the device to receive a stream ? Or connect every X seconds to ask ?

I'm asking this because Sandeep Mistry has made very cool libraries to connect to BLE device with NodeJS and custom data retrieval for Estimote or others. And it works with MetaWare !

I think the first option will not be "live" but fast enought to get some results and will not kill the battery ?

Comments

  • Maintaining an active connection, combined with live streaming, draws a greater amount of power from the battery than letting it operate on its own.  I would go with the IBeacon approach for getting some information on what's happened and use the logger to get a better picture.
  • edited August 2015
    Agreed,

    - I understand how to change iBeacon parameter
    - I understand DataProcessor will filter or update the data
    - I understand Macro will run on board some MetaWare command

    But how can I change Minor version of the iBeacon when the Accelerometer is in motion or shake or ...  DataProcessor / ActivityHandler can't change iBeacon module configuration on board ?

    => The idea is to set the Minor version to a state 0 = WAIT, 1 = MOVING, 2 = SHAKE, 3 = TEMP > 40°C ... then set it back to 0 after a Timer Timeout. So any device (Windows, RPi, Mobile) that can read an iBeacon signal can monitor the MetaWare

  • I believe this can be done with the activity handler.  You would monitor motion detection, shake detection, and a temp -> comparison filter.  Each activity handler would set the Ibeacon minor 

    1. Attach a monitor to motion, shake, and  temp -> comparison processor
    2. Activity handler will set IBeacon minor to 1, 2, 3 for each handler respectively
    3. Schedule a periodic time task that sets the IBeacon minor back to 0 every X seconds
  • Ok I tried something like this

    <pre>
                final IBeacon iBeaconModule= board.getModule(IBeacon.class);
                mma8452qModule.routeData().fromOrientation().monitor(new DataSignal.ActivityHandler() {
                    @Override
                    public void onSignalActive(Map<String, DataProcessor> processors, DataSignal.DataToken token) {
                        IBeacon.ConfigEditor editor = iBeaconModule.configure();
                        editor.setMinor(IBEACON_MOVE).commit();
                        iBeaconModule.enable();
                    }
                });
    </pre>

    - The iBeacon starts when I disconect 
    - But motion seems not to update the minorVersion

    How do you debug that kind of test ? I have to be disconnected so not very easy :-)
  • You need to eliminate as many variables as possible.  
    • Is orientation detection working?
    • Does the activity handler properly trigger other events i.e. turn on led?
  • Orientation logging and streaming works. How do you debug with LED ? (I dont understand the use of a macro in the Exemple)

    I try something stupid like that:

    final Led ledModule = board.getModule(Led.class);
    ledModule.configureColorChannel(Led.ColorChannel.BLUE)
    .setRiseTime((short) 0).setPulseDuration((short) 1000)
    .setRepeatCount((byte) 5).setHighTime((short) 500)
    .setHighIntensity((byte) 16).setLowIntensity((byte) 16)
    .commit();

    switchModule.routeData().fromSensor().monitor(new DataSignal.ActivityHandler() {
    @Override
    public void onSignalActive(Map<String, DataProcessor> processors, DataSignal.DataToken token) {
    ledModule.play(true);
    }
    });

    But I think it's not the right way


  • There is no macro being used in your code block?

    You can try the sample route in the Android Docs for LED debugging:
  • edited September 2015
    Hi Eric,

    The LED on my board didn't work very well with sample app. Sometimes Red is OK then Green and Blue never work.

    I try this simple code:


    final Switch switchModule = board.getModule(Switch.class);
    switchModule.routeData().fromSensor().monitor(new DataSignal.ActivityHandler() {
    @Override
    public void onSignalActive(Map<String, DataProcessor> processors, DataSignal.DataToken token) {
    //iBeaconModule.disable();
    IBeacon.ConfigEditor editor = iBeaconModule.configure();
    editor.setMinor((short) 10).commit();
    //iBeaconModule.enable();
    }
    });
    But as soon as I click on the switch the board "bug" and my detector display "not a beacon". i also try with enable/disable before/after but it change nothing
  • Bump.

    Would it be possible to have a sample ? motion to change minor version of iBeacon ? I'm stuck.
    I'd like to do something like Estimote Stickers.

    Many Thanks !
  • Hrm...it could be the ibeacon module is not working properly with the activity monitor.  I'll have to check with Matt with the ibeacon firmware code.
  • Actually, I have an alternate idea that may work better.  Instead of using iBeacon mode, you can try using the settings module to to manually change the scan rseponse with the setScanResponse method.  Instead of resetting the response after a delay, you can set a timeout delay with setAdInterval so the board will simply stop advertising after a delay, and can restart the advertisement by calling startAdvertisement.
  • @Eric it works very well !

    But I don't know how to get X,Y,Z from token or processor to set more minorValues
This discussion has been closed.