packet_sdk_webos-1.0.*.zip
and unzip it.sdk/service/package.json
and set a correct name attribute, preserve .packet_sdk_service
postfix at the end.sdk/service/services.json
and set a correct id, services[0].id and services[0].name attributes, preserve .packet_sdk_service
postfix at the end.packet_sdk_webos-1.0.*.zip
, integrate PacketSDK in your code. After each start of the JS backend service, subscribe to the status of the SDK through the subscribe_sdk_status
API for future checks on successful integration.
Set the application key through the set_appkey
API.
Start the SDK through the start_packet_sdk
API.
<script src="lib/webOSTV.js" charset="utf-8"></script>
// Replace "luna://com.company.app.packetsdk_service" with your actual URI based on the "name" you set in "Prerequisites-Step 3: Prepare the files".
function subscribeSdkStatus(){
webOS.service.request("luna://com.company.app.packetsdk_service", {
method: "subscribe_sdk_status",
parameters: { subscribe: true },
onSuccess: function (response) {
if(response.code == 0){
let appkey = response.data.appkey;
let sdk_version = response.data.sdk_version;
let sdk_started_status = response.data.sdk_started_status;
let sdk_detailed_status_message = response.data.sdk_detailed_status_message;
}
},
onFailure: function (response) {
console.log("LS2 API 'get_sdk_status' call failed.");
},
});
}
const app_key = "test"; // Replace the "test" with your actual appkey.
function setAppKey(){
webOS.service.request("luna://com.company.app.packetsdk_service", {
method: "set_appkey",
parameters: {
appkey: app_key
},
onSuccess: function (response) {
if(response.code == 0){
console.log("Set appkey successfully, message: " + response.message);
}else{
console.log("Set appkey failed, error code: " + response.code + " error message:" + response.message);
}
},
onFailure: function (response) {
console.log("LS2 API 'set_appkey' call failed.");
}
});
}
function startPacketSDK(){
webOS.service.request("luna://com.company.app.packetsdk_service", {
method: "start_packet_sdk",
parameters: {},
onSuccess: function (response) {
if(response.code == 0){
console.log("Start PacketSDK successfully, message: " + response.message);
}else{
console.log("Start PacketSDK failed, error code: " + response.code + " error message: " + response.message);
}
},
onFailure: function (response) {
console.log("LS2 API 'start_packet_sdk' call failed.");
}
});
}
function stopPacketSDK(){
webOS.service.request("luna://com.company.app.packetsdk_service", {
method: "stop_packet_sdk",
parameters: {},
onSuccess: function (response) {
if(response.code == 0){
console.log("Stop PacketSDK successfully, message: " + response.message);
}else{
console.log("Stop PacketSDK failed, error code: " + response.code + " error message: " + response.message);
}
},
onFailure: function (response) {
console.log("LS2 API 'stop_packet_sdk' call failed.");
}
});
}
set_appkey
and start_packet_sdk
API, if you receive sdk_detailed_status: certification successful
in the subscription SDK status callback function, it indicates that you have successfully integrated Packet SDK into your application.certification successful
in the callback function, you will start seeing devices data and revenue in Packet SDK Dashboard in 24 hours.Inter-process communication protocol: Luna Service 2 API
Please use the actual URI based on the name
you set in Prerequisites-Step3:Prepare the files
. Service URI format example: luna://com.company.app.packetsdk_service
API Description
subscribe_sdk_status - Subscribe to the status of packtsdk, and the callback function will automatically notify you when the sdk status changes.
set_appkey - (Required)
start_packet_sdk - (Required)
stop_packet_sdk
Return code and corresponding meaning