I did sample application for Video communication in webRTC.Its working fine for Chrome but in Firefox its giving iceCandidatefailed error. Can you please suggest me. This is the code having some problem.
Thanks in advance.
function onicecandidate(iceCandidate) {
debugger;
console.log("ice candidate send to room ", iceCandidate);
// send candidates to other guy
if (!peerConnection || !event || !event.candidate) return;
var candidate = event.candidate;
debugger;
var data = {
'type': 'candidate', 'label':candidate.sdpMLineIndex, 'sdpMid':candidate.sdpMid, 'candidate':candidate.candidate
};
socket.emit('message', data);
};
Related
I am trying to send SMS AT+commands using node.js and serial.js with below command but it looks like its skipping the senders number, is this a device problem or something is missing with my code? i am using HUAWEI gsm modem attached on my COM2 and my machine is windows 7.
var SerialPort = require('serialport');
var port = new SerialPort('COM2', {
baudrate: 9600,
dataBits: 8,
parity: 'none'
});
console.log('port is now open');
port.on("open", function () {
console.log('Serial communication open');
port.write("AT");
port.write('\r');
port.on('data', function(data) {
console.log("Received data: " + data);
});
gsm_message_sending(port, "test2", "89410238(example only)");
});
function gsm_message_sending(serial, phone_no, message) {
serial.write("AT+CMGF=1");
serial.write('\r');
serial.write("AT+CMGS=\"" + phone_no + "\"");
serial.write('\r');
serial.write(message);
serial.write(Buffer([0x1A]));
serial.write('^z');
}
I tried to change the line using below code but still the same output.
serial.write("AT+CMGS=\"");
serial.write(phone_no);
serial.write('"')
My console returns below
Any advice would be great! thanks in advance!
I haven't tried your example but, looking at the code, you are calling:
gsm_message_sending(port, "test2", "89410238(example only)");
i.e. the parameters are in the wrong order, it should be:
gsm_message_sending(serial, phone_no, message)
as the title says, I'm trying to publish a message on ros using rosbridge, because my app is written in javascript. Basically i want to cast a stream of heart rate data on a pc running ros to so some elaboration. The app is running on a Tizen based smartwatch. If i try to publish geometry messages, like the device orientation, i have no problem and they are published on ros. I tried the sensor message type (channelfloat32 in particular) to cast the stream of the heart rate with no success. I investigated on the type of the data coming out from the sensor and i discovered that is a number type data of javascript.
So i used the standard message type (Float64 in particular because, as far as i know based on some searching, apparently javascript uses only this type for numbers) with no success again.
Maybe i could cast the variable or change its type, but i don't know if this could be a possible solution and i really don't know how to do it, maybe i only have to change the type of the ros message.
As you can see from my previous questions I'm very new to coding and I'm again on the same project.
Thank you in advance for your help!
Marco
The code is below:
document.addEventListener('tizenhwkey', function(e) {
if(e.keyName === "back")
window.webapis.motion.stop("HRM");
tizen.application.getCurrentApplication().exit();
});
function Connect(){
var ip;
var connection=false;
if (document.getElementById("ip").value==="")
{
ip="10.42.0.1";
}
else
{
ip=document.getElementById("ip").value;
}
var ros = new ROSLIB.Ros({
url : 'ws://' + ip +':9090'
});
ros.on('connection', function() {
connection=true;
document.getElementById("Connection_status").setAttribute("color","green");
document.getElementById("Connection_status").innerHTML = 'Connected';
tizen.power.request("SCREEN", "SCREEN_DIM");
});
ros.on('error', function(error) {
document.getElementById("Connection_status").setAttribute("color","orange");
document.getElementById("Connection_status").innerHTML = 'Error';
});
ros.on('close', function() {
document.getElementById("Connection_status").setAttribute("color","red");
document.getElementById("Connection_status").innerHTML = 'Unconnected';
connection=false;
tizen.power.release("SCREEN");
});
var RatePub = new ROSLIB.Topic({
ros : ros,
name : '/HeartRateData',
messageType : 'std_msgs/Float64'
});
window.webapis.motion.start("HRM", onchangedCB);
function onchangedCB(hrmInfo)
{
var data = hrmInfo.heartRate;
document.getElementById("mytext").innerHTML = 'Heart Rate= ' + data + ' bpm';
var Float64 = new ROSLIB.Message({
data:[data]
});
if(connection===true)
{
RatePub.publish(Float64);
}
else
{
document.getElementById("mytext").innerHTML = 'Heart Rate= 0 bpm';
}
}}
If you are reading HRM data from Tizen wearable device you may use tizen.humanactivitymonitor of Human Activity Monitor API Instead of using window.webapis.motion
Rather using
window.webapis.motion.start("HRM", onchangedCB);
function onchangedCB(hrmInfo) {
var data = hrmInfo.heartRate;
document.getElementById("mytext").innerHTML = 'Heart Rate= ' + data + ' bpm';
...
..
}
You may try
var dataCount = 0;
function onsuccessCB(hrmInfo)
{
console.log("Heart Rate: " + hrmInfo.heartRate);
console.log("Peak-to-peak interval: " + hrmInfo.rRInterval + " milliseconds");
dataCount++;
...
..
if (dataCount > 10){
/* Stop the sensor after detecting a few changes */
tizen.humanactivitymonitor.stop("HRM");
}
}
tizen.humanactivitymonitor.start("HRM", onsuccessCB);
And add the necessary privileges in config.xml file
<tizen:privilege name="http://tizen.org/privilege/healthinfo"/>
<tizen:privilege name="http://tizen.org/privilege/power"/>
According to the Tizen API reference datatype of the heartRate is long.
Please Check the Tizen Human Activity Monitor Guide and Tizen API reference for details implementation.
I am trying to write a cordova hybrid application test application on MobileFirst platform. In my challenge handler, I have included a code to send a login information to my authentication server using submitLoginForm() java script API.
I check using wireshark if any auth request to my authentication server is getting generated, but it does not.
Can you please help me identify the issue with my code?
I can see the alert until Inside handleChallenge3, but does not see the alert for Closing Challenge Handler.
One more thing, I am trying to use isCustomResponse() API just to see what kind of challenge/response is coming to my challenge handler, but it seems not to be getting triggered. Has this been deprecated in MobileFirst Platform 8?
Thanks
var LtpaAuthChallengeHandler = function(){
LtpaAuthChallengeHandler = WL.Client.createWLChallengeHandler("LtpaBasedSSO");
LtpaAuthChallengeHandler.isCustomResponse = function(transport) {
alert ("Inside isCustomResponse");
return true;
};
LtpaAuthChallengeHandler.loginResponse = function(response) {
alert ("Inside loginResponse");
LtpaAuthChallengeHandler.submitSuccess();
alert ("After loginResponse");
};
// handleFailure
LtpaAuthChallengeHandler.handleFailure = function(error) {
// WL.Logger.debug("Challenge Handler Failure!");
if(error.failure !== null && error.failure !== undefined){
alert(error.failure);
}
else {
alert("Unknown error");
}
};
LtpaAuthChallengeHandler.handleChallenge = function(challenge) {
alert ("Inside handleChallenge");
var msg = "";
alert ("Inside handleChallenge1");
var options = {
"headers" : {},
"parameters" : {
"username" : "admin",
"password" : "admin",
'login-form-type' : 'pwd'
}
};
alert ("Inside handleChallenge2");
var loginUrl = "<URI for forms based auth of auth server>";
alert ("Inside handleChallenge3");
LtpaAuthChallengeHandler.submitLoginForm (loginUrl, options, LtpaAuthChallengeHandler.loginResponse);
alert ("Closing Challenge Handler");
};
};
Once the credentials have been collected from the UI, use WLChallengeHandler's submitChallengeAnswer() to send an answer back to the security check.
isCustomResponse() is not applicable from MFP 8.0.
Refer to the Authentication and Security topic here.
Hello,
i searching around the internet, and can't find a full "tutorial", how to write a code, that's if no internet connection automatically shows a error message. I started with the Visual Studio to create a Windows 10 App with Javascript. I searched around, and found some examples with jQuery or AJAX on stackoverflow, but seem's not working for my application. Can someone share a code, that i can put in my application?
I creating a app for my Website, with some addition features, and it's need's internet connection.
Thanks
you can use the NetworkConnectivityLevel, NetworkInformation.getInternetConnectionProfile and getNetworkConnectivityLevel to do this, and show the information with a MessageDialog in the default.js like this:
var connections = Windows.Networking.Connectivity.NetworkInformation.getInternetConnectionProfile();
if (connections != null) {
var networkConnectivityLevel = connections.getNetworkConnectivityLevel();
if (networkConnectivityLevel == Windows.Networking.Connectivity.NetworkConnectivityLevel.internetAccess) {
var msg = new Windows.UI.Popups.MessageDialog("Internet access OK.");
} else if (networkConnectivityLevel == Windows.Networking.Connectivity.NetworkConnectivityLevel.constrainedInternetAccess) {
var msg = new Windows.UI.Popups.MessageDialog("Limited internet access.");
} else if (networkConnectivityLevel == Windows.Networking.Connectivity.NetworkConnectivityLevel.localAccess) {
var msg = new Windows.UI.Popups.MessageDialog("Local network access only.");
} else if (networkConnectivityLevel == Windows.Networking.Connectivity.NetworkConnectivityLevel.none) {
var msg = new Windows.UI.Popups.MessageDialog("No internet access.");
}
msg.showAsync();
} else {
var msg = new Windows.UI.Popups.MessageDialog("No internet access.");
msg.showAsync();
}
$.get('/').fail(function(){
//request failed for some reason. probably internet down
console.log("your internet is down");
});
You can use some HTTP test service as follows:
<html>
<body>
<div id="status" style="width:100px;height:40px;"></div>
<script>
function GetConnectionStatusToElement(element) {
var request = new XMLHttpRequest();
request.open("GET", "https://httpbin.org/", true);
request.onload = function () {
element.innerHTML = "Connected";
};
request.onerror = function () {
element.innerHTML = "Not Connected";
};
request.send();
}
GetConnectionStatusToElement(document.getElementById("status"));
</script>
</body>
<html>
I'm using Ratchet WebSockets and Autobahn.js for two-way client-server communication. I've installed everything, opened the ports, it's been weeks (yes, literally weeks) and it still doesn't work. I think I've narrowed it down to Autobahn's subscribe method not working correctly.
What I'm using is a slight modification of the example code found here:
http://socketo.me/docs/push
Here is my client code:
<script>
window.define = function(factory) {
try{ delete window.define; } catch(e){ window.define = void 0; } // IE
window.when = factory();
};
window.define.amd = {};
</script>
<script src="/apps/scripts/when.js"></script>
<script src="http://autobahn.s3.amazonaws.com/js/autobahn.min.js"></script>
<script>
var conn = new ab.Session(
'ws://light-speed-games.com:8080' // The host (our Ratchet WebSocket server) to connect to
, function() { // Once the connection has been established
console.log('Connection established.');
conn.subscribe('kittensCategory', function(topic, data) {
// This is where you would add the new article to the DOM (beyond the scope of this tutorial)
console.log('New article published to category "' + topic + '" : ' + data.title);
});
}
, function() { // When the connection is closed
console.warn('WebSocket connection closed');
}
, { // Additional parameters, we're ignoring the WAMP sub-protocol for older browsers
'skipSubprotocolCheck': true
}
);
</script>
I believe the problem lies here:
function() { // Once the connection has been established
console.log('Connection established.');
conn.subscribe('kittensCategory', function(topic, data) {
// This is where you would add the new article to the DOM (beyond the scope of this tutorial)
console.log('New article published to category "' + topic + '" : ' + data.title);
});
}
The line console.log('Connection established.'); does its job - it logs its message in the console. However, the conn.subscribe method does nothing. It doesn't matter if I change kittensCategory to any other string, it still does nothing. But kittensCategory is the only thing that makes sense here (see Ratchet's example code through the link above).
Any ideas?
EDIT:
This is the output of ab.debug:
WAMP Connect autobahn.min.js:69
ws://light-speed-games.com:8080 autobahn.min.js:69
wamp autobahn.min.js:69
WS Receive autobahn.min.js:64
ws://light-speed-games.com:8080 [null] autobahn.min.js:64
1 autobahn.min.js:64
[0,"52cbe9d97fda2",1,"Ratchet\/0.3"] autobahn.min.js:64
WAMP Welcome autobahn.min.js:67
ws://light-speed-games.com:8080 [52cbe9d97fda2] autobahn.min.js:67
1 autobahn.min.js:67
Ratchet/0.3 autobahn.min.js:67
Connection established. client.php:15
WAMP Subscribe autobahn.min.js:74
ws://light-speed-games.com:8080 [52cbe9d97fda2] autobahn.min.js:74
kittensCategory autobahn.min.js:74
function (topic, data) {
// This is where you would add the new article to the DOM (beyond the scope of this tutorial)
console.log('New article published to category "' + topic + '" : ' + data.title);
} autobahn.min.js:74
WS Send autobahn.min.js:72
ws://light-speed-games.com:8080 [52cbe9d97fda2] autobahn.min.js:72
1 autobahn.min.js:72
[5,"kittensCategory"]