Skip to content

Latest commit

 

History

History
191 lines (129 loc) · 4.11 KB

README.md

File metadata and controls

191 lines (129 loc) · 4.11 KB

Ti.Disto

Axway Titaniums module for connecting to Disto devices via bluetooth. The official SDK supports Bluetooth, Yeti, USB and Wifi. This module supports at the time only yeti. This is the Leica-Name for BT.

Prerequisites

Permissions in manifest:

 <uses-permission android:name="android.permission.BLUETOOTH" />
 <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

This permission will automaticaly inserted by module de.appwerft.bluetoothmanager

command.json

This file contains all BT-commands and will automaticaly imported from modules asset folder.

Licence key

The SDK need for work a licence key. Currently you can use the public known key (also part of this module) or you can an own one. In this case you can put it into tiapp.xml:

<property 
	name="DISTO_KEY" 
	type="String">1Xj1z6thybdW/O+Jc6XG2ExVzYuY3GF4h+</property>

Usage concept

const LeicaSDK = require("de.appwerft.disto");
const BTManager = require("de.appwerft.bluetoothmanager");


if (LeicaSDK.verifyPermissions() == true) {
	LeicaSDK
		.setLogLevel(LeicaSDK.DEBUG)
		.setTimeout(10000)
		.init(); 
	LeicaSDK.Devicemanager.findAvailableDevices({
		onfound : (e) => {
			const currentDevive = e.device;
			currentDevice.connect({
				ondata : (data) => {
					console.log(data);
				},
				onconnect : () => {
					currentDevice.startTracking();
				}
			});
		}
	});
}

Constants

  • DEVICE_TYPE_BLE
  • DEVICE_TYPE_DISTO
  • DEVICE_TYPE_YETI
  • DEVICE_CONNECTION_STATE_CONNECTED
  • DEVICE_CONNECTION_STATE_DISCONNECTED
  • DEVICE_STATE_NORMAL
  • DEVICE_STATE_UPDATE
  • CONNECTION_TYPE_WIFI_AP
  • CONNECTION_TYPE_WIFI_HOTSPOT

Bluetooth availability

const BT = require("de.appwerft.bluetoothmanager");
var state = BT.getAvailability();

The result can be:

  • NOTAVAILABLE
  • DISABLED
  • ENABLED

In case two you can enable BT by:

import BT from "de.appwerft.bluetoothmanager";

BT.enable({
	onsuccess : handleDisto, // result is name and address of BT on device
	onerror : e => {}
}); 

This opens a system dialog and the user can grant (or not)

Methods of Bluetoothmanager module

getAvailability(): int

Possible results are:

  • NOTAVAILABLE
  • DISABLED
  • ENABLED

This constants are part of sub module Bluetooth.

isAvailable(): boolean

If false then you cannot use this device.

isEnabled(): boolean

If false you can start enable()

enable()

This method has an object with to callbacks: onsuccess and onerror.

Alternatively you can overwrite the onSuccess property:

Bluetooth.onSuccess = (e) => {
	// Disto work
};

disable()

Methods of module

getVersion(): String

init();

Reads the commands.json in modules assets folder. You can use a String paramter for filename. commands.json is default.

verifyPermissions(): boolean

setTimeout

setlogLevel

import Disto from 'de.appwerft.disto';
Disto.setLogLevel(Disto.DEBUG).setTimeout(10000).init();

Methods of DeviceManager

DeviceManager ist available under LeicaSDK.Devicemanager

Devicemanager.findAvailableDevices({})

Properties

  • onfound: Function

Devicemanager.getConnectedDevices(): Device[]

Return a list of device. For every device you can the methods below:

Methods of device

getDeviceID(): String

getDeviceName(): String

connect()

disconnect()

isInUpdateMode(): boolean

getConnectionState(): {name:,code:}

getAvailableCommands(): String[]

getDistance()

Start one measurement.

startTracking()

Start continously measurement

stopTracking()

no comment

toggleTracking()

unpair()

sendCustomCommand(String cmd, Callback)

Roadmap

As mentioned this module only works for Yeti-protocol. On request we can extend the module for usage with other protocols.