COBI.js

devkit The COBI.Bike DevKit opens up the system to create your own ideas. From a tiny dashboard module to a full-scale business tool. Become a DevKit developer

COBI.js is the interface that powers the DevKit modules.

COBI.js lets you interact with the COBI.Bike ecosystem using only JavaScript. Lets us handle the complicated details of Bluetooth connection, CAN BUS, user authentication and many more. Just focus on creating a beautiful user experience for riders.

Quickstart

Include the JavaScript file in your HTML.

<script src="https://cdn.cobi.bike/cobi.js/0.44.0/cobi.js"></script>

Pass an authentication token to the COBI.init function before subscribing to the data stream. Tokens are not issued yet, so you can use any string for now:

// Authenticate your module
COBI.init('token — can be anything right now')
// subscribe to the data stream
COBI.hub.externalInterfaceAction.subscribe(function(action) {
  console.log('I just tapped the handlebar remote and instantly received this ' + action + ' in my Web App');
});

init

The Initialization function. You need to pass your apiKey from the COBI.Bike developer portal in order to start receiving data

Example
COBI.init('token — can by any string right now')

parameters

helper namespace for statical values which can be retrieved by the COBI.Bike native app

Static Members
language()
state()
context()
nativeSdkVersion()

context

The context definitions helps you manage the user experience on your module. You should adapt your webapp content based on the context changes. The context parameter is passed through the URL parameters that a module receives on load

Example
switch(COBI.parameters.context()) {
  case COBI.context.onRide:
    // show something
  case COBI.context.offRide:
    // show something else
  default:
    // ....
}
Static Members
onRide
offRide
onRideSettings
offRideSettings

state

The state definitions helps you manage the user experience on your module. You should adapt your webapp content based on the state changes. Whenever a WebApp is loaded it will receive the respective required Module State via URL

Deprecated: use context instead
Example
switch(COBI.parameters.state()) {
  case COBI.state.edit:
    // show something
  case COBI.state.overview:
    // show something else
  default:
    // ....
}
Static Members
experience
edit
overview

namespaces

These are the namespaced exposed to the web modules to communicate with the native app

app

The app represents the main COBI.Bike user interface running on a mobile device. It can be used to get information about and to manipulate selected UI states and to request and send information to the user.

Static Members
theme
textToSpeech
readLater
language
contact
touchInteractionEnabled
hubLocation
clockVisible
isDark
isHubConnected

hub

The hub is the COBI.Bike device the smartphone is mounted on. When connected to the smartphone, it makes information about it's state and external input available and allows to trigger certain actions. Before usage, a hub has to be activated via the COBI.Bike API (done during the setup on the phone).

Static Members
motorInterfaceReady
bellRinging
externalInterfaceAction
ambientLightState

battery

Static Members
state

motor

The Motor Channel transmits data related to an eBike. The channel only transmits that data if the Hub is actually attached to an eBike. The Bus will not write or read any data until the Ebike System Available Property of the [Main Bus]((#message-bus-channels---main) is true.

Static Members
distance
assistanceIndicator
range
supportedDriveModes
driveMode
nextService

mobile

Channel for reporting hardware-related values

Static Members
location
heading
locationAvailability

Refers to all navigation related information calculated or provided by the navigation engine on the COBI.Bike app

Static Members

user

Channel for reporting user-related information setup in the COBI.Bike app

Static Members
temperatureUnit
lengthUnit

bike

Channel for reporting bike-related configuration parameters

Static Members
type

rideService

Channel for reporting information calculated and provided by the intelligence library in the COBI.Bike app More information

Static Members
speed
userPower
userPowerAvailability
heartRate
heartRateAvailability
cadence
cadenceAvailability

tourService

Channel that describes a bicycle tour as a whole. It contains all statistical data that is available for a tour as well as their status. When a tour is ongoing, the statistical values are updated based on the live values provided by the ride_channel.

concept

Static Members
calories
ascent
ridingDistance
ridingDuration
averageSpeed

devkit

Used by the COBI.js library for developing COBI.Bike modules, the first smart connected biking system.

Static Members
close
overrideThumbControllerMapping

Types

All types known to COBI.js

ExternalInterfaceAction

the action triggered by pressing on a thumb controller

Type: ("UP" | "DOWN" | "LEFT" | "RIGHT" | "SELECT" | "HOME" | "ENTER_BACK" | "UP_POPOVER" | "DOWN_POPOVER" | "LEFT_POPOVER" | "RIGHT_POPOVER")

BatteryState

Type: ("UNKNOWN" | "CHARGING" | "LOW_CHARGE" | "INTERMEDIATE_CHARGE" | "FULL_CHARGE")

PlacemarkCategory

Type: ("NONE" | "FOOD" | "HEALTH" | "LEISURE" | "NIGHTLIFE" | "PUBLIC" | "SERVICE" | "SHOPPING" | "ACCOMODATION" | "TRANSPORT" | "BICYCLE_RELEVANT")

Type: ("STOP" | "PLAN" | "START")

BikeType

Type: ("CITY" | "MTB" | "ROAD" | "URBAN" | "TREKKING")

AmbientLightState

Type: ("DARK" | "TWILIGHT" | "BRIGHT")

Type: ("NONE" | "CALCULATING" | "NAVIGATING")

TemperatureUnit

Type: ("CELSIUS" | "FAHRENHEIT")

MeasurementUnit

Type: ("METRIC" | "IMPERIAL")

RgbColor

Properties
red (number)
green (number)
blue (number)

Theme

Properties
baseColor (RgbColor)
identifier (string)
bundleIdentifier (string)
name (string)
accentColor (RgbColor)
backgroundColor (RgbColor)
logoUrl (string)

BatteryCondition

Properties
batteryLevel (number)
state (BatteryState)

Coordinate

a latitude, longitude pair in decimal degrees format [+-]DDD.DDDDD

Properties
latitude (number)
longitude (number)

Location

the raw location information received from GPS

Properties
coordinate (Coordinate)
altitude (number)
bearing (number)
speed (number)
horizontalAccuracy (number)
verticalAccuracy (number)

Placemark

Properties
name (string)
address (string)
category (PlacemarkCategory)
coordinate (Coordinate)

Route

Properties
origin (Placemark)
destination (Placemark)
name (string)
distance (number)
elevationGain (number)
duration (number)
predefined (boolean)
waypoints (Coordinate)
Properties
action (NavigationAction)
destination (Coordinate)

ReadLaterItem

Properties
title (string)
url (string)

TextToSpeechContent

Properties
language (string)
content (string)

ContactData

Properties
phone (string)
email (string)
url (string)

ServiceTrigger

Motor service data information. Useful to inform the user of a maintenance service check for the bike

Properties
timestamp (number)
distance (number)