Error running 01 46, response: ...UNABLETOCONNECT - android

Getting the data from OBD II simulator to android application via Bluetooth successfully.
Now I am trying get the data from ELM327 device to android application.
I have an ELM327 device connected to my Car. Bluetooth connection happens by ECU connection fails with unable to connect error.
getting below error,
D:NetworkManagementSocketTagger: tagSocket(80) with statsTag=0xffffffff, statsUid=-1
E : Failed to run command. -> Error running 01 46, response: ...UNABLETOCONNECT
Could you please help me to resolve this issue.

i am trying to create an ionic obd-2 application for my university project. i am using "BluetoothSerial" in order to connect with obd simulator i have done all the settings required(that i know of) but i have hit a wall and i dont know what to do next. i connected to the bluetooth device and when is send the "ATZ" commands using bluetoothserial.write(obdcommand) i am getting "OK" can you please share with me how you connected with bluetoothserial or am i missing something...
I will post my code dow below.
obdcommands=['ATD','ATZ','ATE0','ATL0','ATS0','ATH0','ATAT2','ATSP0','0100', '0105\r', '010C'];
constructor(private bluetooth:BluetoothSerial,
private DataSrv:DataSrvService,
private action:ActionSheetController,
private permission:AndroidPermissions,
private alert: AlertController,
private toastctrl:ToastController) {
}
connect(dvc)
{
if(dvc.address=="")
this.showError("No Address");
else{
this.bluetooth.connect(dvc.address).subscribe(success=>
{
this.modal.dismiss(null, 'cancel');
this.presentToast("Connected Successfully");
this.blue=false;
this.deviceConnected();
this.bluetooth.available().then(tr=>{alert(tr)})
},error=>{
alert("Connect Error: "+error);
})
}
}
deviceConnected()
{
this.bluetooth.subscribe('\n').subscribe(success=>{
alert("Subscribed Successfully" +success);
})
}
async searchOBD()
{
for(let k=0;k<this.obdcommands.length;k++)
{
await this.bluetooth.write(this.obdcommands[k]).then( (success) => {
alert('Connected: '+this.obdcommands[k]+'Data: '+success );
},
(error) => {
alert('Reading failed: ' + error );
});
}
}

Related

BLE Pairing gets stuck after Unpairing with nRF Connect App

I encountered a strange problem when trying to unpair and pair again with my smartphone. Currently I write a C# application on UWP (Windows 10) for BLE connection with a remote device. I use my smartphone with nRF Connect App as the peripheral.
After being paired for a while (and being inactive), when unpairing and pairing again, the application gets stuck when trying to pair again.
I broke everything down to the most basal application I could create. This is a Console App that scans the existing devices and then unpairs and pairs with the selected device:
using BLE_Test;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
static async Task Main(string[] args)
{
Dictionary<ulong, string> uuidDict = BleModule.Scan().Result;
Console.WriteLine("Devices found:");
int i = 0;
foreach (var uuid in uuidDict.Keys)
Console.WriteLine(string.Format("ID: {0}, UUID: {1}, Local Name: {2}", i++, uuid, uuidDict[uuid]));
Console.WriteLine("Select ID!");
int id = int.Parse(Console.ReadLine());
ulong selectedUuid = (uuidDict.ElementAt(id)).Key;
await BleModule.Unpair(selectedUuid);
await BleModule.Pair(selectedUuid);
Console.ReadLine();
}
}
}
It calls an UWP DLL called "BLE_Test" with the class "BleModule":
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Windows.Devices.Bluetooth;
using Windows.Devices.Bluetooth.Advertisement;
using Windows.Devices.Enumeration;
namespace BLE_Test
{
public class BleModule
{
public static async Task<Dictionary<ulong, string>> Scan()
{
var uuidDict = new Dictionary<ulong, string>();
BluetoothLEAdvertisementWatcher watcher = new BluetoothLEAdvertisementWatcher();
watcher.Received += (BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs eventArgs)
=> AddAdvertisement(eventArgs, uuidDict);
watcher.Start();
await Task.Delay(10000);
watcher.Stop();
return uuidDict;
}
private static void AddAdvertisement(BluetoothLEAdvertisementReceivedEventArgs eventArgs, Dictionary<ulong, string> uuidDict)
{
if (uuidDict.ContainsKey(eventArgs.BluetoothAddress) == false)
uuidDict.Add(eventArgs.BluetoothAddress, eventArgs.Advertisement.LocalName);
}
public static async Task Pair(ulong uuid)
{
Console.WriteLine("Pairing...");
var bluetoothLEDevice = await BluetoothLEDevice.FromBluetoothAddressAsync(uuid);
if (bluetoothLEDevice == null)
{
Console.WriteLine("UUID not found!");
return;
}
DeviceInformationCustomPairing customPairing = bluetoothLEDevice.DeviceInformation.Pairing.Custom;
customPairing.PairingRequested += (DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args) => args.Accept(); // We auto-accept numeric comparison result for the sake of simplicity
DevicePairingResult result = await customPairing.PairAsync(DevicePairingKinds.ConfirmPinMatch);
Console.WriteLine("Pairing Result: " + result.Status.ToString());
}
public static async Task Unpair(ulong uuid)
{
Console.WriteLine("Unpairing...");
var bluetoothLEDevice = await BluetoothLEDevice.FromBluetoothAddressAsync(uuid);
if (bluetoothLEDevice == null)
{
Console.WriteLine("UUID not found!");
return;
}
DeviceUnpairingResult result = await bluetoothLEDevice.DeviceInformation.Pairing.UnpairAsync();
Console.WriteLine("Unpairing Result: " + result.Status.ToString());
}
}
}
If I start the program for the first time, the pairing works fine (the unpairing will be ignored as the devices are not paired yet). If I start it immediately again afterwards, it also works fine. Unpairing and pairing will both take place. But if I wait a while (typically 5-10 minutes) while not doing anything, when I start the program again, it will unpair, but then it will wait indefinitely for PairAsync() to return. No coupling request will show on the nRF Connect App, and no PairingRequested event will appear.
Aborting the stuck program and restarting it won't help. In this case, even though the smartphone is found by the BluetoothLEAdvertisementWatcher, BluetoothLEDevice.FromBluetoothAddressAsync(uuid) will return null and the device can't be paired anymore. This can only be resolved by restarting the computer or switching off and on the advertisement in the nRF Connect App, as in this case a new random BLE Address is created for the device.
I have taken a snapshot of the BLE events using Btetlparse and Wireshark. It seems that there is a problem with a malformed package:
However, I don't really understand what is going wrong. Is this a problem of the nRF Connect App? Or the UWP commands? Or did I do something wrong? I tried two different smartphones (a Samsung Galaxy and an Oppo), so I doubt that it is a problem of the smartphone. I also added a DeviceWatcher, but this didn't change anything. Can anyone help me here?

Android AWS Kinesis Video Stream: Access to Identity 'us-east-1:xxxxxx' is forbidden

I am trying to connect my app with the AWS Kinesis Video Stream console. I take this aws document as a reference and try to run this official sample app. But every time I try to stream video, app crashes with a NotAuthorizedException exception where Access to Identity 'us-east-1:xxxx' is forbidden is the root cause of the issue. This is the logcat crash report.
2022-03-04 20:12:03.378 1034-1034/com.amazonaws.kinesisvideo.demoapp E/KinesisVideoAndroidClient: 2022-03-04T20:12Z T2: EXCEPTION: ExecutionException: Awaiting for the credentials update threw an exception: com.amazonaws.services.cognitoidentity.model.NotAuthorizedException: Access to Identity 'us-east-1:0axxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxbff' is forbidden. (Service: AmazonCognitoIdentity; Status Code: 400; Error Code: NotAuthorizedException; Request ID: 44739d62-17b9-4aef-b88d-bc72a23da744)
2022-03-04 20:12:03.380 1034-1034/com.amazonaws.kinesisvideo.demoapp W/KinesisVideoClientWrapper: getAuthInfo(): Failed to get the object for the AuthInfo object. methodId �
2022-03-04 20:12:03.380 1034-1034/com.amazonaws.kinesisvideo.demoapp W/KinesisVideoClient: createKinesisVideoClient(): operation returned status code: 0x00000002
2022-03-04 20:12:03.380 1034-1034/com.amazonaws.kinesisvideo.demoapp I/KinesisVideoClientWrapper: throwNativeException(): Had to clear a pending exception found when throwing "Failed to create Kinesis Video client." (code 0x2)
2022-03-04 20:12:03.380 1034-1034/com.amazonaws.kinesisvideo.demoapp D/KinesisVideoClientWrapper: throwNativeException(): Throwing com/amazonaws/kinesisvideo/producer/ProducerException with message: Failed to create Kinesis Video client.
2022-03-04 20:12:03.394 1034-1034/com.amazonaws.kinesisvideo.demoapp E/StreamConfigurationFragment: Failed to create Kinesis Video client
com.amazonaws.kinesisvideo.producer.ProducerException: Failed to create Kinesis Video client. StatusCode: 0x2
at com.amazonaws.kinesisvideo.internal.producer.jni.NativeKinesisVideoProducerJni.createKinesisVideoClient(Native Method)
at com.amazonaws.kinesisvideo.internal.producer.jni.NativeKinesisVideoProducerJni.create(NativeKinesisVideoProducerJni.java:235)
at com.amazonaws.kinesisvideo.internal.producer.jni.NativeKinesisVideoProducerJni.createSync(NativeKinesisVideoProducerJni.java:247)
at com.amazonaws.kinesisvideo.internal.producer.jni.NativeKinesisVideoProducerJni.createSync(NativeKinesisVideoProducerJni.java:212)
at com.amazonaws.kinesisvideo.internal.client.NativeKinesisVideoClient.initializeNewKinesisVideoProducer(NativeKinesisVideoClient.java:219)
at com.amazonaws.kinesisvideo.internal.client.NativeKinesisVideoClient.initialize(NativeKinesisVideoClient.java:136)
I also have noticed that somehow Identity id is different than mine in logcat. I don't know where this us-east-1:0axxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxbff is coming from. This is my awsconfiguration.json:
{
"Version": "1.0",
"CredentialsProvider": {
"CognitoIdentity": {
"Default": {
"PoolId": "us-east-1:5dxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx446",
"Region": "us-east-1"
}
}
},
"IdentityManager": {
"Default": {}
},
"CognitoUserPool": {
"Default": {
"AppClientSecret": "xxxxxxxxxxxxxxxxx...",
"AppClientId": "xxxxx...",
"PoolId": "us-east-1_xxxxxxxxx",
"Region": "us-east-1"
}
}
}
Part of the code where I initialise KVS and the exception gets thrown:
try {
mKinesisVideoClient = KinesisVideoAndroidClientFactory.createKinesisVideoClient(
getActivity(),
KinesisVideoDemoApp.KINESIS_VIDEO_REGION,
KinesisVideoDemoApp.getCredentialsProvider());
} catch (KinesisVideoException e) {
Log.e(TAG, "Failed to create Kinesis Video client", e);
}
getCredentialsProvider():
public class KinesisVideoDemoApp extends Application {
public static Regions KINESIS_VIDEO_REGION = Regions.US_EAST_1;
public static AWSCredentialsProvider getCredentialsProvider() {
return AWSMobileClient.getInstance();
}
...
}
Initially, as the key is different in logcat I thought the default AWSMobileClient.getInstance() is flickering between two identity poles. So I manually tried to access it with the exact key but the result is the same:
try {
mKinesisVideoClient = KinesisVideoAndroidClientFactory.createKinesisVideoClient(
getActivity(),
KinesisVideoDemoApp.KINESIS_VIDEO_REGION,
new CognitoCachingCredentialsProvider(
getApplicationContext(),
"us-east-1:5dxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx446",
Regions.US_EAST_1)
);
} catch (KinesisVideoException e) {
Log.e(TAG, "Failed to create Kinesis Video client", e);
}
As usual, I tried to surf the internet looking for a solution. I take this SlackOverFlow and this Github as a reference and tried all the possible solutions. I make sure:
-> I have the right user pool id and app client id in my identity Authentication Provider Coginito section.
-> Cross verified the signed-up user is listed in user pool.
-> Have the right set of roles both the UnAuth and Auth with right policy in identity pool settings.
Nothing really worked for me. Any kind of help is appreciated! Thank you!

No response to UnityWebRequest on build to http server

I've got an Android app I'm building with Unity that logs info on a simple python http server (hosted on a Digital Ocean Droplet). Here's my coroutine for poking the server:
IEnumerator pokeServer()
{
Debug.Log( "Establishing Server Connectivity..." );
using( var www = UnityWebRequest.Get( ServerURL ) )
{
Debug.Log( "Send Web Request" );
ServerStatus = ConnectionStatuses.AttemptingToConnect;
yield return www.SendWebRequest();
if( www.isNetworkError || www.isHttpError )
{
if( www.isNetworkError )
{
Debug.Log( "NETWORK ERROR: " + www );
}
else
{
Debug.Log( "HTTP ERROR: " + www );
}
ServerStatus = ConnectionStatuses.Unavailable;
}
else
{
Debug.Log( "Success! Server available!" );
ServerStatus = ConnectionStatuses.Connected;
}
}
}
If I run this on the Unity Editor, everything works fine. I can get a response from my server without issue. If I build and run this on an Android, the request is not sent to my server and I get no error message. The last line in the above code that's run is "yield return www.SendWebRequest();"
I've looked at the logcat, and there's no error. My server never gets any requests. However, if I poke "https://www.google.com," I do indeed get a response. This leads me to believe that this is some sort of http vs https issue, but I have no idea where to start. This code has been working for me for a very long time. Any advice would be very welcome!
I'd been using this phone from University of Pennsylvania's wireless network. It turns out that I can make an http request from a desktop but I can't do it from a phone. I took one of the devices home and tried it from my personal wifi and it all worked fine.

Cordova bluetooth plugins

I'm developing android app in cordova where i want read data sent from bluetooth.
I'm testing on Android Lolipop (Sony XPERIA M2) and bluetooth barcode scanner.
For this purpose i tried to use plugins for cordova.
Tested:
https://www.npmjs.com/package/cordova-plugin-bluetoothle
https://www.npmjs.com/package/cordova-plugin-networking-bluetooth
https://github.com/tanelih/phonegap-bluetooth-plugin
https://github.com/don/BluetoothSerial
and many others.
Every time i was possible to find my device but none of these plugins allow me to connect to scanner.
I got error: READ FAILED, SOCKET MIGHT CLOSED OR TIMEOUT, ERROR CODE: 9
My mobile is connected and paired with scanner correctly but i cant figure out why i cant connect via my app.
EDIT:
onDeviceReady: function () {
var dev = {};
app.receivedEvent('deviceready');
window.bluetooth.enable(function () {
alert("SUCCESS");
}, function () {
alert("FAILED");
});
window.bluetooth.startDiscovery(onDeviceDiscovered, onDiscoveryFinished, onError);
function onDeviceDiscovered(device) {
alert("Found device " + device.address);
if (device.address === "40:83:DE:4B:D4:12") { // address of scanner
window.bluetooth.getUuids(onUuidsRetrieved, onError, device.address);
}
}
function onDiscoveryFinished() {
alert("SUCC FINISHED");
if (dev.address === "40:83:DE:4B:D4:12") {
alert("Trying to connect...");
window.bluetooth.connect(onConnected, onErrorConn, {
address: dev.address,
uuid: dev.uuids[0]
});
}
}
function onConnected() {
alert("Connected");
}
function onUuidsRetrieved(device) {
alert(device.address + " UUID: " + device.uuids);
if (device.address === "40:83:DE:4B:D4:12") {
dev = device;
}
}
function onError() {
alert("ERROR");
}
function onErrorConn(error) {
alert(error.code + " " + error.message);
}
}
Was someone facing to same issue ?
Thanks for all your help.
try using the cordova-plugin-networking-bluetooth for the central and for the central I have used cordova-plugin-ble-peripheral.
works great, able to send service and chariteristics changes, and do file transfer

unable to connect to JSON service in android application of Titanium studio

i am trying to do login application which takes id and password..when i click on logi button then it will connect to our local server by JSON..with the specified URL..the code is..
var loginReq = Titanium.Network.createHTTPClient();
loginReq.onload = function()
{
var json = this.responseText; alert(json);
var response = JSON.parse(json);
if (response.data.status == "success")
{ alert("Welcome ");
}
else
{ alert(response.data.status);
}
};
loginReq.onerror = function(event)
{
alert(event.toSource());
//alert("Network error");
};
loginBtn.addEventListener('click',function(e)
{ if (username.value != '' && password.value != '')
{
var url = 'our local url action=login&id='+username.value+'&pwd='+password.value;
loginReq.open("POST",url);
loginReq.send();
}
else
{
alert("Username/Password are required");
}
});
Here it is not connecting our URl..so it is entering into loginReq.onerror function...instead of loginReq.onload function..why it is throwing run time error.. The same code working fine with Iphone..
The Run Time Error is..
TypeError:Cannot call property toSource in object{'source':[Ti.Network.HttpClient],specified url} is not a function,it is a object.
This is wat the error..please let me Know...
Apparently the toSource() function does not exist in android, as it is an object. Try debugging and see what the object event contains.
You could do that by adding a line above the alert line, and adding a debug line to it.
Look in debug mode and see all variables
"toSource()" is not a documented function for either platform, and I also do not see it in the source for Titanium Mobile. If you aren't getting the error on iOS, I'm guessing it is because the error handler isn't getting called. Perhaps your emulator or device does not have internet access, whereas your iOS simulator or device does?
Regardless, error handling in the HTTPClient normally looks something like this:
loginReq.onerror = function(e)
{
Ti.API.info("ERROR " + e.error);
alert(e.error);
};

Categories

Resources