NeoTechni Well-Known Member Licensed User Longtime User Mar 20, 2016 #1 starter_readdata (java line: 305) java.lang.RuntimeException: Service not found at anywheresoftware.b4a.objects.BleManager2.getService(BleManager2.java:260) at anywheresoftware.b4a.objects.BleManager2.readableCharsFromService(BleManager2.java:243) at anywheresoftware.b4a.objects.BleManager2.ReadData2(BleManager2.java:194) at anywheresoftware.b4a.objects.BleManager2.ReadData(BleManager2.java:186) at b4a.example.starter._readdata(starter.java:305) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169) at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:897) at anywheresoftware.b4a.keywords.Common.CallSubNew(Common.java:831) at b4a.example.main._polldata(main.java:1138) at b4a.example.main._sectimer_tick(main.java:1261) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169) at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:105) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:6938) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199) Any thoughts?
starter_readdata (java line: 305) java.lang.RuntimeException: Service not found at anywheresoftware.b4a.objects.BleManager2.getService(BleManager2.java:260) at anywheresoftware.b4a.objects.BleManager2.readableCharsFromService(BleManager2.java:243) at anywheresoftware.b4a.objects.BleManager2.ReadData2(BleManager2.java:194) at anywheresoftware.b4a.objects.BleManager2.ReadData(BleManager2.java:186) at b4a.example.starter._readdata(starter.java:305) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169) at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:897) at anywheresoftware.b4a.keywords.Common.CallSubNew(Common.java:831) at b4a.example.main._polldata(main.java:1138) at b4a.example.main._sectimer_tick(main.java:1261) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169) at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:105) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:6938) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199) Any thoughts?
NeoTechni Well-Known Member Licensed User Longtime User Mar 20, 2016 #2 I tried encapsulating the code in try/catch but it is still crashing. Code: Try manager.ReadData(KeyStart & 0 & KeyEnd) WaitingForData=True Catch WaitingForData=False End Try Upvote 0
I tried encapsulating the code in try/catch but it is still crashing. Code: Try manager.ReadData(KeyStart & 0 & KeyEnd) WaitingForData=True Catch WaitingForData=False End Try
NeoTechni Well-Known Member Licensed User Longtime User Mar 20, 2016 #3 I've double checked and I'm using the right service IDs, as they work one time on the device, but sometimes not the next. Upvote 0
I've double checked and I'm using the right service IDs, as they work one time on the device, but sometimes not the next.
Erel B4X founder Staff member Licensed User Longtime User Mar 20, 2016 #4 Moved to the questions forum. What is the output of Log(KeyStart & 0 & KeyEnd) ? Upvote 0
NeoTechni Well-Known Member Licensed User Longtime User Mar 20, 2016 #5 Public KeyStart As String = "a495ff2", KeyEnd As String = "-c5b1-4b44-b512-1370f02d74de" Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Mar 21, 2016 #6 Based on the error there is no such service. Did you check the available services in the Connected event? Upvote 0
Based on the error there is no such service. Did you check the available services in the Connected event?
NeoTechni Well-Known Member Licensed User Longtime User Mar 21, 2016 #7 There is, as it's a dedicated service for that device for a specific feature, and it's been detecting it fine up till a random point. But is there a way to gracefully fail though? try/catch didn't work. Upvote 0
There is, as it's a dedicated service for that device for a specific feature, and it's been detecting it fine up till a random point. But is there a way to gracefully fail though? try/catch didn't work.
Erel B4X founder Staff member Licensed User Longtime User Mar 22, 2016 #8 You should only access services that are listed in the Connected event. Check whether this specific service is listed or not and do not call it if it doesn't. Upvote 0
You should only access services that are listed in the Connected event. Check whether this specific service is listed or not and do not call it if it doesn't.
NeoTechni Well-Known Member Licensed User Longtime User Mar 23, 2016 #9 It is listed though. It's failing randomly. Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Mar 24, 2016 #10 Recheck your code. The services are discovered once during connection and then the same list of services is used each time. If you want to catch this error then you can use this code: Code: Dim jo As JavaObject = manager Try jo.RunMethod("getService", Array(<your service>)) Manager.ReadData(...) Catch Log("Service not found.") End Try Note that the service id is case sensitive. Upvote 0
Recheck your code. The services are discovered once during connection and then the same list of services is used each time. If you want to catch this error then you can use this code: Code: Dim jo As JavaObject = manager Try jo.RunMethod("getService", Array(<your service>)) Manager.ReadData(...) Catch Log("Service not found.") End Try Note that the service id is case sensitive.