Player APIs (BrightScript & Ja...
JavaScript APIs

bt

11min
the bt object allows you to check if bluetooth is fitted; set, monitor, or retrieve the current ble advertisements; scan for bluetooth devices; and trigger connection to, and disconnection from, another device bt idl enum btcentraleventtype { 'advertising report', 'device found', 'device lost' }; interface btcentraladvertisingreportevent { attribute string adapter path; attribute string device address; attribute int rssi; attribute array\<byte> data; }; interface btcentraldevicefoundevent { attribute string adapter path; attribute string address; attribute string alias; \[optional] attribute string name; \[optional] attribute int rssi; \[optional] attribute int tx power; \[optional] attribute array\<string> uuids; \[optional] attribute array\<byte> advertising flags; \[optional] attribute array\<array\<int, array\<byte>>> manufacturer data; \[optional] attribute map\<string, array\<byte>> service data; }; interface btcentraldevicelostevent { attribute string adapter path; attribute string address; }; typedef (btcentraladvertisingreportevent | btcentraldevicefoundevent | btcentraldevicelostevent) btcentralevent; callback btcentraleventcallback = void (btcentralevent event); interface btcentral { promise\<array\<adapter>> getadapters(); promise\<void> scan(optional scanparameters); promise\<void> stopscan(); void addeventlistener(btcentraleventtype type, btcentraleventcallback callback); void removeeventlistener(btcentraleventtype type, btcentraleventcallback callback); }; interface adapter { attribute string name; attribute bool powered; }; interface scanparameters { attribute bool advertisingreports; }; object creation to create a bt object, first load the brightsign/bt module using the require() method then create an instance of the bt class var btclass = require("@brightsign/bt"); var bt = new btclass(); btcentraladvertisingreportevent adapter path string string required required the adapter that the advertising device belongs to device address string string required required the identifier for a remote advertising device rssi int int required required the signal strength of the device when an advertisement is reported data array\<byte> array\<byte> required required advertisement data btcentraldevicefoundevent indicates if a bluetooth device is found during scanning adapter path string string required required the adapter that the advertising device belongs to address string string required required the unique bluetooth address of the device alias string string required required an alternate name for the remote device name string string optional optional the name of the bluetooth device rssi int int optional optional the signal strength of the device tx power int int optional optional the transmitted power level of the device uuids array\<string> array\<string> optional optional uuid strings advertising flags array\<byte> array\<byte> optional optional the flags used for advertising manufacturer data array\<array\<int, array\<byte>>> array\<array\<int, array\<byte>>> optional optional the manufacturer specific advertisement data keyed by manufacturer id service data map\<string, array\<byte>> map\<string, array\<byte>> optional optional the service advertisement data keyed by uuid btcentraldevicelostevent this is used to report when a bluetooth device is lost adapter path string string required required the adapter that the advertising device belongs to address string string required required the unique bluetooth address of the device btcentral use this interface to perform actions on bluetooth streaming connections getadapters() promise\<array\<adapter>> getadapters() returns an array of adapter identity strings the number of elements in the array is the number of bluetooth adapters fitted scan() promise\<void> scan(optional scanparameters) reports new bluetooth devices as they are discovered it is also possible to monitor raw advertising reports scanparameters optional optional stopscan() promise\<void> stopscan() stops scanning and reporting new bluetooth devices addeventlistener addeventlistener(btcentraleventtype type, btcentraleventcallback callback) this event is raised when the bluetooth status changes use this method to listen for this event see javascript event handling docid\ surgnnhz666sb1wh6pbd9 for more information removeeventlistener removeeventlistener(btcentraleventtype type, btcentraleventcallback callback) use this method to remove an event listener see javascript event handling docid\ surgnnhz666sb1wh6pbd9 for more information adapter in bos versions below 9 1 21 and below 9 0 198, this returns an array of adapter identity strings the number of elements in the array is the number of bluetooth adapters fitted in bos versions above 9 1 21 and 9 0 198, this returns an array of adapter objects name string string powered bool bool whether or not the adapter is powered on scanparameters this interface contains information about a scanned bluetooth streaming device advertisingreports bool bool whether or not scanning for advertisements is active