You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to connect to a Wifi OnBoard Diagnostic(OBD) connector interface for a car's OBD port from my ionic application. But the connection fails with the error message given below my code.
I even changed from $ionicPlatform.ready() to angular.bootstrap method of initializing my app like some other posts had suggested. But still the same issue. Any ideas?
function str2ab(str) {
// var buf = new ArrayBuffer(str.length*2); // 2 bytes for each char
var bufView = new Uint8Array(str.length);
for (var i=0; i<bufView.length; i++) {
bufView[i] = str.charCodeAt(i);
}
return bufView;
}
function connectToHost(host, port) {
var socket = new Socket();
socket.onError = function(errorMessage) {
console.log("Error occured, error: " + errorMessage);
};
socket.onClose = function(hasError) {
console.info("Socket closed, hasErrors=" + hasError);
};
socket.onData = function (data){
var chars = new Array(data.length);
for (var i = 0; i < data.length; i++) {
chars.push(String.fromCharCode(data[i]));
}
var dataString = chars.join("");
console.log(dataString);
};
socket.open(
host,
port,
function(success) {
console.log(success);
},
function(errorMessage) {
console.log("Error during connection, error: " + errorMessage);
}
);
}
$scope.OBDPlugNames = [];
function connectToPlug(){
var config = $cordovaWifiWizard.formatWPAConfig($localstorage.get('wifiName'), $localstorage.get('wifiPassword'));
$cordovaWifiWizard.isWifiEnabled().then(function (bool){
if(bool){//It's enabled
$cordovaWifiWizard.getCurrentSSID().then(function (res){
if(res !== config.SSID){//connected to a wifi network besides the OBDII plug?
$cordovaWifiWizard.disconnect(res).then(function (){//disconnect from current network
$cordovaWifiWizard.connectNetwork(config.SSID)//connect to OBDII plug
.then(function (res){
$scope.OBDConnected = true;
var PID = str2ab("010F0D");
var disableEcho = str2ab("ATE0");
connectToHost('MY_IP', MY_PORT)
});
});
} else {
$cordovaWifiWizard.connectNetwork(config.SSID)//connect to OBDII plug
.then(function (res){
$scope.OBDConnected = true;
var PID = str2ab("010F0D");
var disableEcho = str2ab("ATE0");
connectToHost('MY_IP', MY_PORT)
});
}
});
} else {//it's disabled
$ionicPopup.alert({
template: "<h3>Wifi is disabled</h3><br><strong><p>Please enable wifi and try again</p></strong>"
});
}
});
}
returns the following error;
Error during connection, error: failed to connect to /MY_IP (port MY_PORT): connect failed: ENETUNREACH (Network is unreachable)
The text was updated successfully, but these errors were encountered:
I'm trying to connect to a Wifi OnBoard Diagnostic(OBD) connector interface for a car's OBD port from my ionic application. But the connection fails with the error message given below my code.
I even changed from
$ionicPlatform.ready()
toangular.bootstrap
method of initializing my app like some other posts had suggested. But still the same issue. Any ideas?returns the following error;
The text was updated successfully, but these errors were encountered: