Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

Properties

adParser

Private adapterEventNames

adapterEventNames: object

Type declaration

  • [key: number]: string

catAdapter

catAdapter: Category

Private charManagers

charManagers: object

Type declaration

Private characteristicNames

characteristicNames: object

Type declaration

  • [key: number]: string

Private config

config: any

connectedDevice

connectedDevice: IOTileDevice | null

Private connectionHooks

connectionHooks: ConnectionHookCallback[]

connectionMessages

connectionMessages: any[]

interactive

interactive: boolean

lastScanResults

lastScanResults: IOTileAdvertisement[]

mockBLEService

mockBLEService: any

notification

Private platform

platform: Platform

Private preconnectionHooks

preconnectionHooks: PreconnectionHookCallback[]

rpcInterface

rpcInterface: IOTileRPCInterface

Private scriptInterface

scriptInterface: IOTileScriptInterface

state

Private streamingInterface

streamingInterface: IOTileStreamingInterface

Private supportsFastWrites

supportsFastWrites: boolean

Private tracingInterface

tracingInterface: IOTileTracingInterface

Private tracingOpen

tracingOpen: boolean

Methods

addNotificationListener

  • ngdoc

    method

    name

    iotile.device.service:IOTileAdapter#addNotificationListener

    methodof

    iotile.device.service:IOTileAdapter

    description

    Listen for notifications on a specific BLE characteristic known to IOTileAdapter.

    This is an async method!

    If this is the first call to addNotificationListener on this characteristic, the BLE stack is called to enable notifications. However, if this is a subsequent call, it will complete immediately since nofications have already been enabled. The listener will just be added to an internal table of notification listeners for that characteristic

    Parameters

    Returns Promise<function>

    Asynchronously returns a function that takes no arguments and removes this notification listener when called. The signature of the function returned is () => Promise

Private checkFastWriteSupport

  • checkFastWriteSupport(peripheral: BLEPeripheral): boolean

Private checkProperty

  • checkProperty(char: BLECharacteristic, propToFind: string): boolean

clearTrace

  • clearTrace(): void

Private closeInterface

  • closeInterface(iface: Interface): Promise<void>

connect

  • ngdoc

    method

    name

    iotile.device.service:IOTileAdapter#connect

    methodof

    iotile.device.service:IOTileAdapter

    description

    Connect to an IOTileDevice.

    This is an async method

    This method connects to an IOTile device over bluetooth. If there is already an IOTile device connected, it throws an error.

    example
    var foundAdverts = await IOTileAdapter.scan(1.0);
    if (foundAdverts.length > 0) {
      var device = await IOTileAdapter.connect(foundAdverts[0]);
    }
    

    Parameters

    • advert: IOTileAdvertisement

      The IOTileDevice object that we should connect to. This device should been returned from a previous call to IOTileAdapter.scan.

    • options: ConnectionOptions

      (optional) Configure what checks and and actions are performed automatically on connection without any required interaction. By default, the RPC interface is opened and streaming is started.

    Returns Promise<IOTileDevice>

Private connectInternal

  • Connect to a device using the internal cordova BLE plugin

    This function is a bit complicated because of the plugin's API. There are two callbacks provided to the plugin: onConnected and onDisconnected

    onConnected is called with no arguments after we succesfully connect onDisconnected is called in two circumstances:

    • if we did not connect successfully, in which case we reject the promise
    • if we subsequently get disconnected from the BLE device, in which case the promise is gone and we instead notify that we were disconnected by calling disconnectCallback.

    Parameters

    Returns Promise<IOTileDevice>

connectTo

  • ngdoc

    method

    name

    iotile.device.service:IOTileAdapter#connectTo

    methodof

    iotile.device.service:IOTileAdapter

    description

    Connect to an IOTileDevice that has previously been scanned given its slug.

    This is an async method

    This method connects to an IOTile device over bluetooth. If there is already an IOTile device connected, it throws an error.

    Raises a ConnectionError if the device slug cannot be found in previously scanned devices.

    Parameters

    • slug: string

      The slug of the device that we want to connect to

    • options: ConnectionOptions

      (optional) Configure what checks and and actions are performed automatically on connection without any required interaction. By default, the RPC interface is opened and streaming is started.

    Returns Promise<IOTileDevice>

Private createChannel

  • Create a channel object that can write and subscribe to characteristics over BLE. Channels are passed to the subinterfaces inside this IOTileAdapter in order to give them the ability to actually talk to the IOTile device without creating a public API for low level writes and notifications.

    The BLEChannel interface is intended to be minimalist and only all the required operations.

    Returns BLEChannel

Private createIOTileAdvertisement

disconnect

  • disconnect(): Promise<void>
  • ngdoc

    method

    name

    iotile.device.service:IOTileAdapter#disconnect

    methodof

    iotile.device.service:IOTileAdapter

    description

    Disconnect from any currently connected IOTile Device.

    This is an async method!

    This method can never fail. After the method returns, the IOTile adapter will be in an Idle state and able to scan for or connect to other IOTile devices.

    Returns Promise<void>

Private disconnectCallback

  • disconnectCallback(reason: any): void
  • Callback provided to ble plugin that is called whenever a device gets disconnected or if the connection attempt fails.

    Parameters

    • reason: any

    Returns void

Private disconnectInternal

  • disconnectInternal(deviceID: any): Promise<void>
  • Internally in BLE central plugin, the possible responses are:

    • in Android, there is no way for disconnect to fail. The disconnect attempt is scheduled and then resolve is called.

    Parameters

    • deviceID: any

    Returns Promise<void>

enableTracing

  • enableTracing(): Promise<void>

enabled

  • enabled(): Promise<boolean>
  • ngdoc

    method

    name

    iotile.device.service:IOTileAdapter#enabled

    methodof

    iotile.device.service:IOTileAdapter

    description

    Return is BLE is enabled on the device.

    This is an async method!

    Returns Promise<boolean>

    Whether or not BLE is enabled on the device

Private ensureConnected

  • ensureConnected(action: string, userMessage?: undefined | string): void

Private ensureIdle

  • ensureIdle(action: string): void
  • Ensure the Adapter is in an idle state before proceeding

    Parameters

    • action: string

    Returns void

errorHandlingRPC

  • errorHandlingRPC(address: number, rpcID: number, callFormat: string, respFormat: string, args: (string | number | ArrayBuffer)[], timeout?: undefined | number): Promise<any[]>
  • ngdoc

    method

    name

    iotile.device.service:IOTileAdapter#errorHandlingRPC

    methodof

    iotile.device.service:IOTileAdapter

    description

    Type converting wrapper around rpc() that throws if the first argument of response is nonzero

    This is an async method!

    This function sends a single RPC to an IOTile device and waits for it to finish before returning. Internally it calls IOTileAdapter.rpc() to make the actual RPC call but this function builds the payload ArrayBuffer from a list of integers and a format code. Similarly, it decodes the response into a list of numbers as well.

    If an error occurs calling the RPC, an exception is thrown indicating what went wrong. If the error is unrecoverable, further RPCs to the device will not be allowed without disconnecting and reconnecting.

    The RPC called must return a uint32_t as the first 4 bytes of its response and this value is checked to ensure it is zero. If it is nonzero, an exception is thrown rather saying there was an error executing the RPC.

    The list of values returned does not include the error code since it will always be zero.

    Parameters

    • address: number

      The address of the tile that we want to send the RPC to

    • rpcID: number

      The 16 bit id of the RPC that we would like to call

    • callFormat: string

      A format code passed to packArrayBuffer to convert a list of numbers into an ArrayBuffer. Examples would be "LH" to pack an unsigned 32 bit integer followed by a 16 bit integer.

    • respFormat: string

      A format code passed to unpackArrayBuffer to convert the response Callback into a list of numbers that are returned.

    • args: (string | number | ArrayBuffer)[]

      An array of arguments that should match the format of callFormat and is used to construct the payload for this RPC. The first item (the error code) is shifted off and not returned.

    • Optional timeout: undefined | number

      The maximum amount of time that we would like to wait for this RPC to finish.

    Returns Promise<any[]>

    The decoded list of numbers that were returned from the RPC (excluding the error code).

Private findCharacteristic

  • findCharacteristic(peripheral: BLEPeripheral, service: string, charName: string): BLECharacteristic | null
  • Parameters

    • peripheral: BLEPeripheral
    • service: string
    • charName: string

    Returns BLECharacteristic | null

getConnectedDevice

  • ngdoc

    method

    name

    iotile.device.service:IOTileAdapter#getConnectedDevice

    methodof

    iotile.device.service:IOTileAdapter

    description

    Get the currently connected device. If there is no device currently connected, returns null.

    Returns IOTileDevice | null

    {IOTileDevice} The currently connected device or null if no device is connected currently.

Private notify

Private openInterface

  • openInterface(iface: Interface): Promise<void>

pause

  • pause(): void

registerConnectionHook

  • ngdoc

    method

    name

    iotile.device.service:IOTileAdapter#registerConnectionHook

    methodof

    iotile.device.service:IOTileAdapter

    description

    Register a function to be called everytime someone connects to a device

    The function should be asynchronous and throw an exception if there is an error inside the hook that means the device should not be connected to. If any hook throws an exception, the device is disconnected from and that error is thrown to whomever tried to connect to the device.

    The signature of the method should be (IOTileDevice, IOTileAdapter) => Promise

    Parameters

    Returns void

registerPreconnectionHook

  • ngdoc

    method

    name

    iotile.device.service:IOTileAdapter#registerPreconnectionHook

    methodof

    iotile.device.service:IOTileAdapter

    description

    Register a function to be called before someone connects to a device

    The function should be asynchronous and return a boolean. If the function returns true, we can proceed with the connection. If the function returns false, the connection attempt will be stopped.

    The signature of the method should be (IOTileDevice, IOTileAdapter) => Promise

    Parameters

    Returns void

Private removeNotificationListener

  • ngdoc

    method

    name

    iotile.device.service:IOTileAdapter#removeNotificationListener

    methodof

    iotile.device.service:IOTileAdapter

    description

    Remove a previously installed notification listener.

    This is an async method!

    This will deregister a callback that was listening for notified data on a characteristic. If this is the last callback registered on that characteristic, notifications will also be stopped.

    Parameters

    • char: IOTileCharacteristic

      A numerical identifier for the characteristic that we want notifications about.

    • handlerID: number

      the ID of the callback that should be removed, which is returned from the call to addNotificationListener.

    Returns Promise<void>

    A promise that is fullfilled when the listener has been removed

resetStreaming

  • resetStreaming(): void

resume

  • resume(): void

rpc

  • rpc(address: number, rpcID: number, payload: ArrayBuffer, timeout?: undefined | number): Promise<ArrayBuffer>
  • ngdoc

    method

    name

    iotile.device.service:IOTileAdapter#rpc

    methodof

    iotile.device.service:IOTileAdapter

    description

    Send an RPC to a connected IOTile device

    This is an async method!

    This function sends a single RPC to an IOTile device and waits for it to finish before returning. Internally the RPC is queued so that multiple users calling this function from different places simultaneously will properly be synchronized.

    This is provisional API that will change.

    Parameters

    • address: number

      The address of the tile that we want to send the RPC to

    • rpcID: number

      The 16 bit id of the RPC that we would like to call

    • payload: ArrayBuffer

      The payload that we would like to send

    • Optional timeout: undefined | number

      The maximum amount of time that we would like to wait for this RPC to finish.

    Returns Promise<ArrayBuffer>

scan

  • ngdoc

    method

    name

    iotile.device.service:IOTileAdapter#scan

    methodof

    iotile.device.service:IOTileAdapter

    description

    Scan for devices for a fixed period of time.

    This is an async method!

    Returns a list of IOTileAdvertisement objects for the IOTile devices that were found.

    Side Effects:

    • Notifies on AdapterEvent.ScanStarted when scanning has been started
    • Notifies on AdapterEvent.ScanFinished when scanning has finished.

    AdapterEvent.ScanFinished has one argument with a count property that contains the number of IOTile devices that were found. See the ScanFinishedArgs interface.

    example
    //Scan for 1 second and return the devices seen
    var foundDevices = await IOTileAdapter.scan(1.0);
    console.log("Found " + foundDevices.length + " IOTile devices!");
    

    Parameters

    • scanPeriod: number

      The number of seconds to scan

    Returns Promise<IOTileAdvertisement[]>

    A list of the IOTile devices seen during the scan

sendScript

  • sendScript(script: ArrayBuffer, notifier: any): Promise<void>

Private setReportSize

stopScan

  • stopScan(): Promise<void>

subscribe

  • ngdoc

    method

    name

    iotile.device.service:IOTileAdapter#subscribe

    methodof

    iotile.device.service:IOTileAdapter

    description

    Subscribe to notifications on IOTileDevice related events.

    Currently supports scan started and scan finished events. The notifications proceed using the angular event system. You may pass a scope object and all notifications you register will be automatically removed when your scope is destroyed. If you are calling this method from a service, you can pass null for the scope to not automatically deregister the handler on scope destruction.

    Parameters

    • event: AdapterEvent

      The event that you want to subscribe to, must be an event in IOTileAdapterModule.AdapterEvent.

    • callback: function

      The function that will be called when the event happens. callback must have the signature callback(object) => void.

        • (string: string, any: any): void
        • Parameters

          • string: string
          • any: any

          Returns void

    Returns any

    A function that will deregister this handler before the scope is destroyed if necessary.

typedRPC

  • typedRPC(address: number, rpcID: number, callFormat: string, respFormat: string, args: (string | number | ArrayBuffer)[], timeout?: undefined | number): Promise<any[]>
  • ngdoc

    method

    name

    iotile.device.service:IOTileAdapter#typedRPC

    methodof

    iotile.device.service:IOTileAdapter

    description

    Type converting wrapper around rpc()

    This is an async method!

    This function sends a single RPC to an IOTile device and waits for it to finish before returning. Internally it calls IOTileAdapter.rpc() to make the actual RPC call but this function builds the payload ArrayBuffer from a list of integers and a format code. Similarly, it decodes the response into a list of numbers as well.

    If an error occurs calling the RPC, an exception is thrown indicating what went wrong. If the error is unrecoverable, further RPCs to the device will not be allowed without disconnecting and reconnecting.

    Parameters

    • address: number

      The address of the tile that we want to send the RPC to

    • rpcID: number

      The 16 bit id of the RPC that we would like to call

    • callFormat: string

      A format code passed to packArrayBuffer to convert a list of numbers into an ArrayBuffer. Examples would be "LH" to pack an unsigned 32 bit integer followed by a 16 bit integer.

    • respFormat: string

      A format code passed to unpackArrayBuffer to convert the response Callback into a list of numbers that are returned.

    • args: (string | number | ArrayBuffer)[]

      An array of arguments that should match the format of callFormat and is used to construct the payload for this RPC.

    • Optional timeout: undefined | number

      The maximum amount of time that we would like to wait for this RPC to finish.

    Returns Promise<any[]>

    The decoded list of numbers that were returned from the RPC.

waitForTracingData

  • waitForTracingData(numBytes: number, timeout?: number): Promise<ArrayBuffer>
  • Wait for a given number of bytes to be received on the tracing interface.

    If no data has been received in more than 1 second after calling this function, the promise returned will be rejected by the tracing interface watchdog timer, making sure that the interface cannot stall. The recommended way to use this function is to trigger some event that sends data via the tracing interface (after making sure the interface is open...) and then calling:

    let data: ArrayBuffer = await adapter.waitForTracingData(numBytes);
    

    That is all that is required to synchronously receive that number of bytes from the tracing interface.

    Parameters

    • numBytes: number

      The number of bytes to wait for. This exact number of bytes will be returned to you when the Promise is resolved.

    • Default value timeout: number = 1000

      The number of milliseconds to wait before receiving another chunk of tracing data before we give up and abort the wait (rejecting the promise). This defaults to 1000 ms if not passed.

    Returns Promise<ArrayBuffer>

Private write

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc