How to call RPC via BLE (e.g. for WiFi setup)

#1

Take a look at https://mongoose-os.com/ble/#/
This is a Web (JavaScript) client, which works on Google Chrome browser only (it has BLE support).
The core logic in contained in this file: https://mongoose-os.com/ble/js/rpc_over_ble.js , which implements a blerpc function:

var blerpc = async function(dev, method, params) {
  ...
};

And this is how that function is called by the https://mongoose-os.com/ble/js/main.js:

var params = {
  config: {
    wifi: {
      ap: {enable: false},
      sta: {
        enable: true,
        ssid: 'SSID',
        pass: 'PASSWORD',
      }
    }
  }
};
blerpc(app.state.device, 'Config.Set', params)
    .then(function(f) {
      blerpc(app.state.device, 'Config.Save', {reboot: true})
    })
    .then(function() {
      alert('done.');
    })
    .catch(function(err) {
      alert(err);
    });
1 Like
#2

A useful tool - but worth noting that it only works on Chrome desktop. Chrome on iOS doesn’t work (haven’t checked Android).

Ironically, if you try it on Chrome for iOS it says “…not supported… Please use Chrome”. Would be helpful to reword this.

1 Like