scan ble beacon on Samsung gear s2: result null for RSSI reading

437 Views Asked by At

I'm trying to scan a Sensorberg BLE beacon with my Samsung Gear S2. I would like to get the txpowerlvl by reading the advertisement data. I'm using Tizen Studio with updated firmware on my Gear S2.

The scan sometimes detects the txpowerlvl but sometimes produces zero results (the txpowerlvl is null). I have tried to simulate Beacon signals from my iPhone and it could detect them, but the txpowerlvl is always null.

I presume there is a problem with Bluez or its API. Some have had success with CSR bluetooth boards, but why doesn't it work with my Sensorberg beacon (or my iPhone)?

This is my main.js

var BLEconnect = document.getElementById("BLEconnect");
var BLEstopscan = document.getElementById("BLEstopscan");
var BLEdisconnect = document.getElementById("BLEdisconnect");
var remoteDevice = null;
var adapter = tizen.bluetooth.getLEAdapter();
var myhandler1 = function () {
function connectFail(error)
{
 console.log("Failed to connect to device: " + e.message);
}
function connectSuccess()
{
     console.log("Connected to device");
}
function showGATTService(service, indent)
{
 if (indent === undefined)
 {
 indent = "";
 }
     console.log(indent + "Service " + service.uuid + ". Has " + service.characteristics.length
     + " characteristics and " + service.services.length + " sub-services.");
 for (var i = 0; i < service.services.length; i++)
 {
 showGATTService(service.services[i], indent + " ");
 }
}   

function onDeviceFound(device)
{
 if (remoteDevice === null)
 {
 remoteDevice = device;
 console.log("Found device name: " + device.name + " txpowerlevel: " +         device.txpowerlevel + " . Connecting...");
 device.connect(function connectSuccess()
 {      
     console.log("Connected to device");

     var i = 0, service = null;
     var serviceUUIDs = remoteDevice.uuids;
     console.log("remoteDevice.uuids: "+ serviceUUIDs);
     console.log("remoteDevice.uuids.length :"+ serviceUUIDs.length);
     for (i; i < serviceUUIDs.length; i++)
     {
     service = remoteDevice.getService(serviceUUIDs[i]);
     showGATTService(service);
     }      

 } , connectFail);      
 }
 adapter.stopScan();
}
adapter.startScan(onDeviceFound);   
}
var myhandler2 = function () {
remoteDevice.disconnect();
}
var myhandler3 = function () {
adapter.stopScan()
}
BLEconnect.addEventListener("click", myhandler1, false);
BLEdisconnect.addEventListener("click", myhandler2, false);
BLEstopscan.addEventListener("click", myhandler3, false);
window.onload = function() {

document.addEventListener('tizenhwkey', function(e) {
 if (e.keyName === "back") {
try {
tizen.application.getCurrentApplication().exit();
} catch (ignore) {}
}
});

This is my sdb dblog

 I/BLUETOOTH_FRWK_API( 4592): bt-adapter-le.c: bluetooth_stop_le_discovery(131) >←[32m Sync Request => type=BT_BLUEZ_SERVICE, fn=BT_STOP_LE_DISCOVERY(0x12) ←[0m
E/CAPI_NETWORK_BLUETOOTH( 4592): bluetooth-adapter.c: bt_adapter_le_stop_scan(2398) > NOT_IN_PROGRESS(0xfe400105)
I/BLUETOOTH_FRWK_API( 4592): bt-adapter-le.c: bluetooth_start_le_discovery(111)> ←[32m Sync Request => type=BT_BLUEZ_SERVICE, fn=BT_START_LE_DISCOVERY(0x11) ←[0m
I/CAPI_NETWORK_BLUETOOTH( 4592): bluetooth-common.c: __bt_le_event_proxy(2399) >Need to check 2 slots in the case
I/CAPI_NETWORK_BLUETOOTH( 4592): bluetooth-common.c: __bt_le_event_proxy(2429) >BLUETOOTH_EVENT_REMOTE_LE_DEVICE_FOUND
E/WRT_PLUGINS/TIZEN( 4592): BluetoothLEDevice.cpp: BluetoothLEDevice(59) > Failed to get txpower strength from scan response: -61
E/WRT_PLUGINS/TIZEN( 4592): BluetoothLEDevice.cpp: BluetoothLEDevice(63) > Failed to get txpower strength from advertise data: -61
E/WRT_PLUGINS/TIZEN( 4592): BluetoothLEDevice.cpp: BluetoothLEDevice(77) > Failed to get appearance value from scan response: -61
E/WRT_PLUGINS/TIZEN( 4592): BluetoothLEDevice.cpp: BluetoothLEDevice(81) > Failed to get appearance value from advertise data: -61
E/WRT_PLUGINS/TIZEN( 4592): BluetoothLEDevice.cpp: BluetoothLEDevice(96) > Failed to get service data list from scan response: -61
E/WRT_PLUGINS/TIZEN( 4592): BluetoothLEDevice.cpp: BluetoothLEDevice(100) > Failed to get service data list from advertise data: -61
E/WRT_PLUGINS/TIZEN( 4592): BluetoothLEDevice.cpp: BluetoothLEDevice(148) > Failed to get the service solicitation UUID list from scan response: -61
E/WRT_PLUGINS/TIZEN( 4592): BluetoothLEDevice.cpp: BluetoothLEDevice(152) > Failed to get the service solicitation UUID list from advertise data: -61
E/WRT_PLUGINS/TIZEN( 4592): BluetoothLEDevice.cpp: BluetoothLEDevice(167) > Failed to get the service service_uuids list from scan response: -61
I/BLUETOOTH_FRWK_API( 4592): bt-device.c: bluetooth_connect_le(352) > ←[32m ###Connect LE ←[0m
I/BLUETOOTH_FRWK_API( 4592): bt-device.c: bluetooth_connect_le(355) > ←[32m Async Request => type=BT_BLUEZ_SERVICE, fn=BT_CONNECT_LE(0x159) ←[0m
I/BLUETOOTH_FRWK_API( 4592): bt-adapter-le.c: bluetooth_stop_le_discovery(131) >←[32m Sync Request => type=BT_BLUEZ_SERVICE, fn=BT_STOP_LE_DISCOVERY(0x12) ←[0m
W/WECONN ( 540): <__on_bt_adapter_le_advertising_state_changed_cb:1489> result(0), state(0)
I/CAPI_NETWORK_BLUETOOTH( 4592): bluetooth-common.c: __bt_event_proxy(2108) > BLUETOOTH_EVENT_ADVERTISING_STARTED
E/CAPI_NETWORK_BLUETOOTH( 4592): bluetooth-adapter.c: _bt_adapter_le_invoke_advertising_state_cb(2120) > No available advertiser
I/CAPI_NETWORK_BLUETOOTH( 4592): bluetooth-common.c: __bt_event_proxy(1751) > BLUETOOTH_EVENT_GATT_CONNECTED
E/WECONN ( 540): <_bt_gatt_client_get_service:3219> ret : -61
I/BLUETOOTH_FRWK_API( 4592): bt-device.c: bluetooth_is_device_connected(318) > ←[32m Sync Request => type=BT_BLUEZ_SERVICE, fn=BT_IS_DEVICE_CONNECTED(0x5a) ←[0m
I/BLUETOOTH_FRWK_API( 4592): bt-gatt-client.c: bluetooth_gatt_get_primary_services(320) > +
I/CAPI_NETWORK_BLUETOOTH( 4592): bluetooth-gatt.c: _bt_gatt_client_update_services(190) > Service handle[0] /org/bluez/hci0/dev_7D_4C_09_B1_16_A6/service0056
I/BLUETOOTH_FRWK_API( 4592): bt-gatt-client.c: bluetooth_gatt_get_service_property(257) > ======> Service : c4d8e0c7-24b7-48ba-81c1-1b6280fdb3a6 [Unknown]
I/CAPI_NETWORK_BLUETOOTH( 4592): bluetooth-gatt.c: _bt_gatt_client_update_services(190) > Service handle[1] /org/bluez/hci0/dev_7D_4C_09_B1_16_A6/service0053
I/BLUETOOTH_FRWK_API( 4592): bt-gatt-client.c: bluetooth_gatt_get_service_property(257) > ======> Service : 59b02dbf-ef00-4f8c-b470-51cae194d838 [Unknown]
I/CAPI_NETWORK_BLUETOOTH( 4592): bluetooth-gatt.c: _bt_gatt_client_update_services(190) > Service handle[2] /org/bluez/hci0/dev_7D_4C_09_B1_16_A6/service0050
I/BLUETOOTH_FRWK_API( 4592): bt-gatt-client.c: bluetooth_gatt_get_service_property(257) > ======> Service : 00001802-0000-1000-8000-00805f9b34fb [Immediate Alert]
I/CAPI_NETWORK_BLUETOOTH( 4592): bluetooth-gatt.c: _bt_gatt_client_update_services(190) > Service handle[3] /org/bluez/hci0/dev_7D_4C_09_B1_16_A6/service0044
I/BLUETOOTH_FRWK_API( 4592): bt-gatt-client.c: bluetooth_gatt_get_service_property(257) > ======> Service : 89d3502b-0f36-433a-8ef4-c502ad55f8dc [Apple Media Service]
I/CAPI_NETWORK_BLUETOOTH( 4592): bluetooth-gatt.c: _bt_gatt_client_update_services(190) > Service handle[4] /org/bluez/hci0/dev_7D_4C_09_B1_16_A6/service003a
I/BLUETOOTH_FRWK_API( 4592): bt-gatt-client.c: bluetooth_gatt_get_service_property(257) > ======> Service : 7905f431-b5ce-4e99-a40f-4b1e122d00d0 [Apple Notification Center Service]
I/CAPI_NETWORK_BLUETOOTH( 4592): bluetooth-gatt.c: _bt_gatt_client_update_servic
es(190) > Service handle[5] /org/bluez/hci0/dev_7D_4C_09_B1_16_A6/service0035
I/BLUETOOTH_FRWK_API( 4592): bt-gatt-client.c: bluetooth_gatt_get_service_property(257) > ======> Service : 0000180a-0000-1000-8000-00805f9b34fb [Device Information]
I/CAPI_NETWORK_BLUETOOTH( 4592): bluetooth-gatt.c: _bt_gatt_client_update_services(190) > Service handle[6] /org/bluez/hci0/dev_7D_4C_09_B1_16_A6/service002f
I/BLUETOOTH_FRWK_API( 4592): bt-gatt-client.c: bluetooth_gatt_get_service_property(257) > ======> Service : 00001805-0000-1000-8000-00805f9b34fb [Current Time Service]
I/CAPI_NETWORK_BLUETOOTH( 4592): bluetooth-gatt.c: _bt_gatt_client_update_services(190) > Service handle[7] /org/bluez/hci0/dev_7D_4C_09_B1_16_A6/service002b
I/BLUETOOTH_FRWK_API( 4592): bt-gatt-client.c: bluetooth_gatt_get_service_propety(257) > ======> Service : 0000180f-0000-1000-8000-00805f9b34fb [Battery Service]
I/CAPI_NETWORK_BLUETOOTH( 4592): bluetooth-gatt.c: _bt_gatt_client_update_services(190) > Service handle[8] /org/bluez/hci0/dev_7D_4C_09_B1_16_A6/service000a
I/BLUETOOTH_FRWK_API( 4592): bt-gatt-client.c: bluetooth_gatt_get_service_property(257) > ======> Service : d0611e78-bbb4-4591-a5f8-487910ae4366 [Unknown]
I/CAPI_NETWORK_BLUETOOTH( 4592): bluetooth-gatt.c: _bt_gatt_client_update_services(190) > Service handle[9] /org/bluez/hci0/dev_7D_4C_09_B1_16_A6/service0006
I/BLUETOOTH_FRWK_API( 4592): bt-gatt-client.c: bluetooth_gatt_get_service_property(257) > ======> Service : 00001801-0000-1000-8000-00805f9b34fb [Generic Attribute]
I/CAPI_NETWORK_BLUETOOTH( 4592): bluetooth-gatt.c: _bt_gatt_client_update_services(190) > Service handle[10] /org/bluez/hci0/dev_7D_4C_09_B1_16_A6/service0001
I/BLUETOOTH_FRWK_API( 4592): bt-gatt-client.c: bluetooth_gatt_get_service_property(257) > ======> Service : 00001800-0000-1000-8000-00805f9b34fb [Generic Access]
I/CAPI_NETWORK_BLUETOOTH( 4592): bluetooth-gatt.c: bt_gatt_client_create(2496) > GATT Client Handle is created
I/BLUETOOTH_FRWK_API( 4592): bt-gatt-client.c: bluetooth_gatt_get_characteristics_property(654) > Characteristic : b2433de2-ef79-4168-8288-c0ef8f0fcff8 [Unknown]
I/BLUETOOTH_FRWK_API( 4592): bt-gatt-client.c: __get_permission_flag(555) > permission = read
E/WRT_PLUGINS/TIZEN( 4592): BluetoothGATTCharacteristic.cpp: BluetoothGATTCharacteristic(48) > Watch callback couldn't be registred
I/BLUETOOTH_FRWK_API( 4592): bt-gatt-client.c: bluetooth_gatt_get_characteristics_property(654) > Characteristic : 00002a06-0000-1000-8000-00805f9b34fb [Alert Level]
E/WRT_PLUGINS/TIZEN( 4592): BluetoothGATTCharacteristic.cpp: BluetoothGATTCharacteristic(48) > Watch callback couldn't be registred

This is my console.log

Found device name: Heart Rate txpowerlevel: null . Connecting... app.js:40
Connected to device app.js:44
remoteDevice.uuids: 180A,180D app.js:48
remoteDevice.uuids.length :2 app.js:49
Service 0000180a-0000-1000-8000-00805f9b34fb. Has 9 characteristics and 0 sub-services. app.js:26
Service 0000180d-0000-1000-8000-00805f9b34fb. Has 3 characteristics and 0 sub-services. app.js:26
0

There are 0 best solutions below