How to troubleshoot this error after trying to make a BackGroud Service ? Error: Illegal Access (Out of Bounds) Details: Failed invoking <symbol> Stack: - initialize() at .......chapp1App.mc:27 0x10000026

On the file from App I Have:

(:background)
class watchapp1App extends Application.AppBase {
     hidden var scanner;
     hidden var model;
     private var _view;

function initialize() {
     AppBase.initialize();

     model = new ResultsModel(); <---- this is the line that the error present, no issue before try to join a background on this project
     scanner = new Scanner(model);

function getInitialView() {
     //register for temporal events if they are supported
     if(Toybox.System has :ServiceDelegate) {
          canDoBG=true;
          Background.registerForTemporalEvent(new Time.Duration(5 * 60));
          System.println("Registo Efectuado BackGround - TRUE");
     } else {
          System.println("****background not available on this device****");
     }
     _view = new watchapp1View(model);
     return [ _view, new KeyHandler(scanner) ];
}

function getServiceDelegate() as ServiceDelegate{
     return new BackGServiceDelegate();
}

On my Background file:

(:background)
class BackGServiceDelegate extends Toybox.System.ServiceDelegate {

     function initialize() {
          Sys.ServiceDelegate.initialize();
          //inBackground=true; //trick for onExit()
          Sys.println("inBackGround: TRUE");
     }
function onTemporalEvent() {
     System.println("TTTTEEEEMMMPPPOOORRRAAALLLLLLL");
     Background.exit(null);
}
}

Im using the CIQ, i receive the error message every 5 minutes ( but no movement on onTemporalEvent())

With the same code I manage to start a new App and runs just fine (the temporal event).

I'm noob on this, can anyone help me ? thanks in advance

  • Could you provide further details about this issue involving more than three items?

    Certainly, I'll attempt it with more than three items and will inform you of the results when finished.

    I'll be utilizing eight BLE sensors, though not all concurrently. They are placed throughout the house, and I'll be recording the movement data of the person with the 'VA4'.

    Here's my approach:

    • I'll receive the data and store it in a dictionary.
    • After a certain duration or amount of data accumulation, I'll save it to disk (using Storage.setValue).
    • In the background, I'll retrieve the stored data using getValue.
    • Finally, I'll send the data via HTTP request.

    Apologies for the inquiry, but do you think this plan is manageable?

  • Not sure what/how you're trying to do things. but in the API doc for CIQ BLE. there is this for registerProfile

    https://developer.garmin.com/connect-iq/api-docs/Toybox/BluetoothLowEnergy.html#registerProfile-instance_function

    registerProfile(profile as { :uuid as BluetoothLowEnergy.Uuid, :characteristics as Lang.Array<{ :uuid as BluetoothLowEnergy.Uuid, :descriptors as Lang.Array<BluetoothLowEnergy.Uuid> }> }) as Void

    Registers a Bluetooth Profile Definition

    Call this function to define all of the Profiles that will be used in the application. Only registered characteristics and descriptors will be available when performing GATT operations

    When the operation is completed BleDelegate.onProfileRegister() will be called on the registered delegate with the UUID and a Status

    Registration can fail if too many profiles are registered, the current limit is 3.

    You may also want to check out
    https://developer.garmin.com/connect-iq/api-docs/Toybox/BluetoothLowEnergy.html#getAvailableConnectionCount-instance_function

  • If the sensors are all the same, BLE wise, profile, etc, I do something similar as I have a few pi devices in the house running the same app.

    When I want data, I start scanning and connect to one of them.  I limit which one based on the RSSI so I ignore ones that are too far.  Sitting here with one of the pi device maybe 2 feet away, I see an RSSI of -60 or so

    Oh. one more thing to note, is the BLE range can vary based on which Garmin.  I forget how the va4 was, but in my case, I have a pi I talk to with BLE to control my garage door.  With some,, I'll connect when pulling into the driveway, and others, I need to be right at the door and hold the device right next to the window closest to the pi.