Skip to content

Instantly share code, notes, and snippets.

@tomayac
Created April 7, 2016 09:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomayac/faa06cb4f34506ba0e5f785f183c7ad8 to your computer and use it in GitHub Desktop.
Save tomayac/faa06cb4f34506ba0e5f785f183c7ad8 to your computer and use it in GitHub Desktop.
// From https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx
var services = [
'alert_notification',
'automation_io',
'battery_service',
'blood_pressure',
'body_composition',
'bond_management',
'continuous_glucose_monitoring',
'current_time',
'cycling_power',
'cycling_speed_and_cadence',
'device_information',
'environmental_sensing',
'generic_access',
'generic_attribute',
'glucose',
'health_thermometer',
'heart_rate',
/* 'http_proxy' DOMException: Failed to execute 'requestDevice' on 'Bluetooth': Invalid Service name: 'http_proxy'.,*/
/* 'human_interface_device', DOMException: requestDevice() called with a filter containing a blacklisted UUID. https://goo.gl/4NeimX*/
'immediate_alert',
'indoor_positioning',
'internet_protocol_support',
'link_loss',
'location_and_navigation',
'next_dst_change',
/* 'object_transfer' DOMException: Failed to execute 'requestDevice' on 'Bluetooth': Invalid Service name: 'object_transfer'.,*/
'phone_alert_status',
'pulse_oximeter',
'reference_time_update',
'running_speed_and_cadence',
'scan_parameters',
/* 'transport_discovery' DOMException: Failed to execute 'requestDevice' on 'Bluetooth': Invalid Service name: 'transport_discovery'.,*/
'tx_power',
'user_data',
'weight_scale'
];
navigator.bluetooth.requestDevice({filters: [{services: services}]
}).then(device => {
console.log(device);
}).catch(error => {
console.log(error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment