Evothings Viewer v1.5 at large with BLE updates

Mikael KindborgBlogs, Tutorials

Tweet about this on TwitterShare on FacebookShare on LinkedInShare on Google+

We recently published a new version of Evothings Viewer for Android and iOS.

Read on to learn about the new features and prepare for a quick hands-on experience!

Highlights in Evothings Viewer 1.5

  • Updated BLE API with support for pairing/bonding
  • QR-code and Barcode Scanner
  • Updated tutorials and documentation

Below we take a look at these new features.

Updated BLE API

The Cordova BLE plugin that is included in Evothings Viewer has an enhanced API that makes it easy to code mobile apps that communicate over Bluetooth Low Energy. The API is now easier to use and includes support for pairing/bonding with BLE devices on Android and iOS.

Remember that an Evothings app is 100% Cordova compatible, and that you can use the BLE plugin in apps you publish on the app stores.

QR-code scanner

IMG_1794Now you can scan QR-codes and Barcode from Evothings Viewer. This has many uses in the IoT Industry. This is also a Cordova plugin that is bundled with Evothings Viewer, which you can also use in your own apps.

Hands on with the new APIs (5 minutes)

Here is how you can try out the new functionality in Evothings Viewer.

  • Download Evothings Workbench to your computer and install it. Follow instructions on the download page.
  • Install Evothings Viewer from the Apple App Store (iOS) or Google Play (Android).
  • Connect from the Viewer to the Workbench.

Normally you run apps from the Workbench and edit code in a text editor, but this time we will use a somewhat hidden feature of Evothings Workbench, the JavaScript code console.

First click the Console button in the upper-right corner of the Workbench window.

In the upper half of the JavaScript console window you can evaluate code dynamically in the connected Viewer app.

To check that the connections works (remember you must be connected from the Viewer to the Workbench), type this into the Console window:

1+2

Select this text and click the “EVAL SELECTION” button. The result should be displayed in the lower half of the Console window.

Scan a QR-code or Barcode

Copy and paste this code into the Console window, select the code and click “EVAL SELECTION”:

cordova.plugins.barcodeScanner.scan(
  function (result) {
    hyper.log('We got a barcode\n' +
      'Result: ' + result.text + '\n' +
      'Format: ' + result.format + '\n' +
      'Cancelled: ' + result.cancelled)
  },
  function (error) {
    hyper.log('Scanning failed: ' + error)
  })

You will first see “RES: undefined” in the result window, this is beacuse the code we selected does return undefined. Then once you scanned a code, you will see the textual representation of it.

For additional details, see the Barcode Scanner API reference at the plugin home page.

Find nearby BLE devices

Now we will use the BLE plugin API to scan for nearby BLE devices.

Copy the following code into the JavaScript console window, select it and click “EVAL SELECTION”:

evothings.ble.startScan(
  function (device) {
    hyper.log('Found device: ' + device.name + ' rssi: ' + device.rssi)
  },
  function (error) {
    hyper.log('BLE scan failed: ' + error)
  })

This will print the name of found devices and their RSSI (signal strength) to the console.

To stop scanning EVAL this code snippet:

evothings.ble.stopScan()

To get a taste of what’s in the Evothings BLE API, check out the BLE API Guide on the documentation website.

Read the BLE plugin release notes on GitHub for details about pairing/bonding.

100% Cordova Compatible

Evothings Viewer is itself a Cordova app, and if you are interested in the details have a look at the Viewer source code on GitHub.

Get Started Easily

If you skipped the above hands-on coding, just download Evothings Workbench and run some example apps. Try e.g. the BLE Scan example app. It does what the above code snippets does, but wrapped in an application user interface.

Stay prepared for updates from us about industrial strength app development for IoT. BLE app development has never been easier!