BlueTooth connection alarm on a watchface

Hi,

I would add an alarm on my watchface, when bluetooth is disconnected from my phone.

I have add something like this in my background class

    function onConnectedStateChanged( device, state ) {
            var connected;
            if(state==Toybox.BluetoothLowEnergy.CONNECTION_STATE_CONNECTED) {
                connected = true;
                Sys.println("connected");        
            } else {
                connected=false;
                Sys.println("disconnect - new scan");
            }
            makeAlarm(connected);
    }
But on the simulator, I don't know how to simulate a connection (or disconnection). With Setting-->Connection type-->BLE-->connected (or not) Nothing happen
Could someone help me ?
Thanks
  • You are talking two very different things here The general BLE to your phone for things like syncing, notifications, weather etc.

    BluetoothLowEnergy is generally used to talk to sensors.  See the NordicThingy52 samples in the SDK,

    Sound to me what you want to do (no background service needed) is watch System.DeviceSettings.phoneConnected and if the phone becomes disconnect, save the time.  Then check the time and if it's longer than a specific time, display a message on your watch face.  Watchfaces aren't allowed to make a sound of vibrate,

  • Hum, yes, I just have discovered what is BLE, that's new for me, I didn't know what it is, and this is not what I need.

    I only want to be notified when my phone is diconnected, and I will use what you say (System.DeviceSettings.phoneConnected). 

    I have implemented System.DeviceSettings.phoneConnected, and it's OK.

    Just missing sound or vibration, and that's a shame, because my phone is a medical device for me (diabete with AAPS)

    Thanks a lot for your help