How can I get the MAC address a from Samsung Smart TV in JavaScript?
I tried the code below but nothing happens:
function getMAC() {
var mac = null;
try {
mac = webapis.network.getMac();
} catch (e) {
addResult("getMAC exception [" + e.code + "] name: " + e.name
+ " message: " + e.message);
}
if (null != mac) {
addResult("[getMAC] mac: " + mac);
}
}
Check you TV is running on Tizen.
Check config.xml has <tizen:privilege name="http://developer.samsung.com/privilege/network.public"/>
And... I think you already make the addResult function but just make it if you don't.
Related
So I am trying to test out bluetooth connectivity with some code. Whenever I try to scan for bluetooth devices I do not get a pop-up to allow for it so it keeps waiting for it. I know the code works because we are working in group and it works on the MacOS computer my partner has but it is not working on my windows. I mainly want it to scan for an ESP with BLE. I already enabled the 'Experimental Web Platform features' and the 'Use the new permissions backend for Web Bluetooth' flags and made sure my Chrome is updated and made sure the permissions for bluetooth scanning and devices are enabled.
console.log("Init");
document.getElementById("scan").onclick = scan;
navigator.bluetooth.addEventListener("advertisementreceived", (event) => {
console.log("Advertisement", event);
});
async function scanDevices() {
const devices = await navigator.bluetooth.getDevices();
console.log(devices);
}
async function scan() {
console.log("Scanning...");
let options = {
acceptAllAdvertisements: true,
};
try {
log("Requesting Bluetooth Scan with options: " + JSON.stringify(options));
const scan = await navigator.bluetooth.requestLEScan(options);
log("Scan started with:");
log(" acceptAllAdvertisements: " + scan.acceptAllAdvertisements);
log(" active: " + scan.active);
log(" keepRepeatedDevices: " + scan.keepRepeatedDevices);
log(" filters: " + JSON.stringify(scan.filters));
navigator.bluetooth.addEventListener("advertisementreceived", (event) => {
log("Advertisement received.");
log(" Device Name: " + event.device.name);
log(" Device ID: " + event.device.id);
log(" RSSI: " + event.rssi);
log(" TX Power: " + event.txPower);
log(" UUIDs: " + event.uuids);
event.manufacturerData.forEach((valueDataView, key) => {
logDataView("Manufacturer", key, valueDataView);
});
event.serviceData.forEach((valueDataView, key) => {
logDataView("Service", key, valueDataView);
});
});
setTimeout(stopScan, 10000);
function stopScan() {
console.log("Scan result", scan);
log("Stopping scan...");
scan.stop();
log("Stopped. scan.active = " + scan.active);
}
} catch (error) {
log("Argh! " + error);
}
}
function log(c) {
console.log(c);
}
Use requestDevice to pop up chooser UI.
const device = await navigator.bluetooth.requestDevice(options)
this is my scenario: I have a barcodeScanner ionic plugin in my Ionic application, that is installed on a tablet where I cannot use hardware buttons.
My code:
this.barcodeScanner.scan(option).then((result) => {
console.dir(
"We got a barcode\n" +
"Result: " + result.text + "\n" +
"Format: " + result.format + "\n" +
"Cancelled: " + result.cancelled
);
this.product_code = result.text;
if(result.text !== "" && result.text !== null)
{
return this.searchByBarcode(result.text);
}
}, (err) => {
// An error occurred
});
Question
Is there a way to close the plugin after a certain amount of time if no barcode is scanned (or to insert a software button inside the plugin)?
I am trying to include the barcode scanner plugin for phonegap (phonegap 5.1.1) and I can't make it work (https://github.com/phonegap/phonegap-plugin-barcodescanner)
First of all, I installed the plugin running:
phonegap plugin add phonegap-plugin-barcodescanner
Then I have a javascript function:
function leerBarCode(){
//navigator.notification.alert("LLega a leerBarCode", alertDismissed, "Mensaje", "OK");
cordova.plugins.barcodeScanner.scan(function (result) {
alert("We got a barcode\n" +
"Result: " + result.text + "\n" +
"Format: " + result.format + "\n" +
"Cancelled: " + result.cancelled);
}, function (error) {
alert("Scanning failed: " + error);
});
}
When I click over a button that calls to this function, it doesn't launch the camera. Please, can you help me?
I am sending messages through local connection web to Air application .
IE, Firefox and Safari are successfuly sending messages.
But chrome is failing in sending.(Only when PPAPI)
Why isn't Chrome PPAPI Local connection sending message?
Reference:
LocalConnection - AS3
Unsandbox LocalConnections in Chrome
Website flash as3 - send fart
private function receivedFromJavaScript(value:String):void
{
//var conn:LocalConnection;
//trace("JavaScript says: " + value + "\r");
ExternalInterface.call("sendToJavaScript", + value );
conn = new LocalConnection();
conn.client = new Object();
//conn.allowDomain('app#Myapplication');
//conn.allowInsecureDomain('app#Myapplication')
conn.addEventListener(StatusEvent.STATUS, onStatus);
conn.addEventListener(AsyncErrorEvent.ASYNC_ERROR,function(e:AsyncErrorEvent):void
{
//trace("ASYNC_ERROR: " + e );
ExternalInterface.call("sendToJavaScript", "ASYNC_ERROR: " + e );
});
conn.addEventListener(SecurityErrorEvent.SECURITY_ERROR,function(e:SecurityErrorEvent):void
{
ExternalInterface.call("sendToJavaScript", "SECURITY_ERROR: " + e );
//trace("SECURITY_ERROR: " + e );
});
conn.send("app#Myapplication:taskConnection", "localconnectionHandler", value);
ExternalInterface.call("sendToJavaScript", "conn = " + conn.client.toString() + " / " + conn.domain);
//conn.close();
}
AIR applcation code
try {
conn = new LocalConnection();
conn.allowDomain("*");
conn.client = this;
conn.connect("taskConnection");
trace("yes.");
} catch (error:ArgumentError) {
trace("Can't connect.");
}
It is a bug.
You can use a workaround disabling PPAPI plugin from the settings page:
http://www.maipiusenza.com/LDV/images/hlp_pic41.gif
Here you can read a discussion in the Adobe's forum
https://forums.adobe.com/thread/1045650?start=0&tstart=0
I periodically check for a fix, but I'm still waiting!
You need to set the flash file atttributes on your swf file. If you run this:
./flashfileattributes mySWFfile.swf –verboseOnly
./flashfileattributes mySWFfile.swf +brokerLocalConnection
then local connection works fine in Chrome.
When working on Selenium user-extension, how can you call a Selenium Command?
When debugging Selenium User Extension, how can you echo/console.log ?
Could find the answer on the internet so I'm posting my own answer below
To call a Selenium Command in user-extension.js, you need to use this syntax
this.doCommandName(param)
ie, to call echo
Selenium.prototype.doMyFunction = function(){
this.doEcho("This info will show on logs");
}
Perhaps this works even better. As now the debug messages of your user extension are similar as the debug and info messages of 'build-in' commands.
Selenium.prototype.doYourCommand = function(strTarget, strValue) {
LOG.debug("begin: doBaseURL | " + strTarget + " | " + strValue + " |");
LOG.info(strValue);
LOG.debug("end: doBaseURL | " + strTarget + " | " + strValue + " |");
}