DeveloperTools | Firebolt

DeveloperTools Module


Version 0.1.0-alpha.4

Overview

A module for supporting off-device developer tools.

OpenRPC

Firebolt APIs are maintained in the rdkcentral/firebolt-manage-sdk.git GitHub repository.

You can see this API in the developertools.json OpenRPC JSON-Schema document.

Table of Contents

 

Usage

To use the DeveloperTools module, you can import it into your project from the Firebolt SDK:

import { DeveloperTools } from '@firebolt-js/manage-sdk'

Methods

find

Starts a long-running DNS-SD search for a list of developer tools that match the standard ‘Firebolt Developer Tool’ service type

function find(add: function, remove: function): Promise<Process>

Parameters:

Param Type Required Summary
add function true Callback to pass any DeveloperTool[] objects to, as they become available
remove function false Callback to pass any DeveloperTool[] objects to, as they become unavailable

Promise resolution:

interface Process {
    stop(): void // Stops updating this temporal set with DeveloperTool[] objects
}

Examples

Default Example

JavaScript:

const process = DeveloperTools.find(function(
    tool => {
        console.log('Added to temporal set:')
        console.dir(tool)
    },
    tool => {
        console.log('Removed from temporal set:')
        console.dir(tool)
    })

setTimeout( () => process.stop(), 10000)

Value of tool:

[
  {
    "id": "ff6340fb-8576-494c-97c6-e60e9a4eeba9",
    "name": "A tool"
  }
]
JSON-RPC:

Request:

[
    {
  "jsonrpc": "2.0",
  "id": 1,
  "method": "developertools.find",
  "params": {}
},
    {
        "id": 2,
        "method": "ontoolAvailable",
        "params": {
            "listen": true
        }
    }
]

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    {
      "id": "ff6340fb-8576-494c-97c6-e60e9a4eeba9",
      "name": "A tool"
    }
  ]
}

listen

Listen for events from this module.

To listen to a specific event pass the event name as the first parameter:

DeveloperTools.listen(event: string, (data: any) => void): Promise<bigint>

Parameters:

Param Type Required Summary
event string Yes The event to listen for, see Events.
callback function Yes A function that will be invoked when the event occurs.

Promise resolution:

Type Description
bigint Listener ID to clear the callback method and stop receiving the event, e.g. DeveloperTools.clear(id)

Callback parameters:

Param Type Required Summary
data any Yes The event data, which depends on which event is firing, see Events.

To listen to all events from this module pass only a callback, without specifying an event name:

DeveloperTools.listen((event: string, data: any) => void): Promise<bigint>

Parameters:

Param Type Required Summary
callback function Yes A function that will be invoked when the event occurs. The event data depends on which event is firing, see Events.

Callback parameters:

Param Type Required Summary
event string Yes The event that has occured listen for, see Events.
data any Yes The event data, which depends on which event is firing, see Events.

Promise resolution:

Type Description
bigint Listener ID to clear the callback method and stop receiving the event, e.g. DeveloperTools.clear(id)

See Listening for events for more information and examples.


once

Listen for only one occurance of an event from this module. The callback will be cleared after one event.

To listen to a specific event pass the event name as the first parameter:

DeveloperTools.once(event: string, (data: any) => void): Promise<bigint>

Parameters:

Param Type Required Summary
event string Yes The event to listen for, see Events.
callback function Yes A function that will be invoked when the event occurs.

Promise resolution:

Type Description
bigint Listener ID to clear the callback method and stop receiving the event, e.g. DeveloperTools.clear(id)

Callback parameters:

Param Type Required Summary
data any Yes The event data, which depends on which event is firing, see Events.

To listen to all events from this module pass only a callback, without specifying an event name:

DeveloperTools.once((event: string, data: any) => void): Promise<bigint>

Parameters:

Param Type Required Summary
callback function Yes A function that will be invoked when the event occurs. The event data depends on which event is firing, see Events.

Callback parameters:

Param Type Required Summary
event string Yes The event that has occured listen for, see Events.
data any Yes The event data, which depends on which event is firing, see Events.

Promise resolution:

Type Description
bigint Listener ID to clear the callback method and stop receiving the event, e.g. DeveloperTools.clear(id)

See Listening for events for more information and examples.


pair

Configures Firebolt to accept incoming Firebolt JSON RPC messages from the developer tool identified by the given developer tool ID

function pair(id: string): Promise<void>

Parameters:

Param Type Required Summary
id string true The ID of the DeveloperTool to which to connect
format: uuid

Promise resolution:

void

Examples

Default Example

JavaScript:

import { DeveloperTools } from '@firebolt-js/manage-sdk'

DeveloperTools.pair("ff6340fb-8576-494c-97c6-e60e9a4eeba9")
    .then(result => {
        console.log(result)
    })

Value of result:

null
JSON-RPC:

Request:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "developertools.pair",
  "params": {
    "id": "ff6340fb-8576-494c-97c6-e60e9a4eeba9"
  }
}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": null
}

unpair

Disconnect Firebolt as a web socket client from the web socket that corresponds to the given developer tool ID

function unpair(id: string): Promise<void>

Parameters:

Param Type Required Summary
id string true The ID of the DeveloperTool from which to disconnect
format: uuid

Promise resolution:

void

Examples

Default Example

JavaScript:

import { DeveloperTools } from '@firebolt-js/manage-sdk'

DeveloperTools.unpair("ff6340fb-8576-494c-97c6-e60e9a4eeba9")
    .then(result => {
        console.log(result)
    })

Value of result:

null
JSON-RPC:

Request:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "developertools.unpair",
  "params": {
    "id": "ff6340fb-8576-494c-97c6-e60e9a4eeba9"
  }
}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": null
}

Additional methods

The following methods are documented as part of a related set of method APIs.

For more information, follow the links under the “Documentation” column.

JavaScript RPC Parameters Documentation
NA stopFind (correlationId: string)  

Events

Additional events

The following events are documented as part of a related set of method APIs.

For more information, follow the links under the “Documentation” column.

JavaScript RPC Payload Documentation
NA onToolAvailable DeveloperTool  
NA onToolUnavailable DeveloperTool  

Schemas

DeveloperTool

type DeveloperTool = {
  id: string            // The ID that uniquely identifies this instance of a developer tool
  name: string          // Developer-visible 'friendly name' for the developer tool
}

Go To Top