How to get subscription respond on webApp?

i added permissions to use ble apis like below

{
"id": "com.test-rssi.app",
"version": "0.0.1",
"vendor": "ssafy",
"type": "web",
"main": "index.html",
"title": "test-rssi",
"icon": "icon.png",
"requiredPermissions": [
"time.query",
"activity.operation",
"bluetooth.management",
"bluetooth.operation"
]

and made variables like this,
(all beacon names are "ESP" same and major&minor number different.)

var getRssiApi = 'luna://com.webos.service.bluetooth2/le/startScan';
var getBEACONParams = '{"subscribe": true,"name":"ESP"}'

but idk how to get Subscription responses...

Response :

{
"subscribed": true,
"returnValue": true,
"adapterAddress": "b8:27:eb:1b:4f:01",
}

and thats all.

by using WebOSServiceBridge, how can i get Subscription responses?

do i need to make js service or native service?
is making js service while running webApp possible?

i finally made my app receive real-time rssi datas,

by making JS service to subscribe

'luna://com.webos.service.bluetooth2/le/startScan'

but I was not satisfied with refreshing rate...

idk how to keep Bluetooth2 API active.

Any solution?

can i use com.webos.service.activitymanager to

com.webos.service.bluetooth2?

Hi @ChangyongAhn,

Below snippet is the sample code for subscribing response.

function test(){

       var bridge = new WebOSServiceBridge();
       var url = 'luna://com.webos.service.bluetooth2/le/startScan';
       var params = '{"subscribe":true,"name":"ESP"}';

       function callback(msg){
           var arg = JSON.parse(msg);
           console.log("Response:",arg)
       }

       bridge.url = url;
       bridge.onservicecallback = callback;
       bridge.call(url, params);

 }

test();
1 Like