Xamarin PCL Bluetooth can't see devices - android

I'm trying to using xamarin for do a test app.
This app must search bluetooth devices, view them into a list and connect to them for read or write data.
I choose xamarin Portable Class Library for my project.
I see a lots of examples but I can't see devices in my list.
I try Monkey Robotics (project 'Robocontroller' and project 'BLE') but scanning I can't see devices!
Robocontroller:
05-30 15:14:21.048 D/Mono (11792): [0x7f6946d000] worker starting
05-30 15:14:21.063 I/mono-stdout(11792): BluetoothLEManager: Scan timeout has elapsed.
BluetoothLEManager: Scan timeout has elapsed.
05-30 15:14:21.065 D/BluetoothAdapter(11792): stopLeScan()
05-30 15:14:21.067 D/BluetoothAdapter(11792): 622203304: getState(). Returning 12
BLE:
Adapter: Starting a scan for devices.
05-30 15:23:53.549 D/BluetoothAdapter(17688): startLeScan(): null
05-30 15:23:53.647 D/BluetoothLeScanner(17688): onClientRegistered() - status=0 clientIf=5
adapter.StartScanningForDevices(00000000-0000-0000-0000-000000000000)
05-30 15:23:53.755 I/mono-stdout(17688): adapter.StartScanningForDevices(00000000-0000-0000-0000-000000000000)
[0:] adapter.StartScanningForDevices(00000000-0000-0000-0000-000000000000)
05-30 15:23:53.768 I/Choreographer(17688): Skipped 152 frames! The application may be doing too much work on its main thread.
Thread started: <Thread Pool> #7
05-30 15:24:03.718 D/Mono (17688): [0xba2bcf40] worker starting
BluetoothLEManager: Scan timeout has elapsed.
05-30 15:24:03.801 I/mono-stdout(17688): BluetoothLEManager: Scan timeout has elapsed.
05-30 15:24:03.808 D/BluetoothAdapter(17688): stopLeScan()
I tryed others projects like 'estimotes', 'xamarin BLE' (the one with old code that redirect to Monkey.Robotics) and 'BluetoothLEExplorer'.
I'm using latest version of xamarin with vs2015 pro.
Any suggestions?
Thanks

Using BLE you can't see another bluetooth devices (like android phone), must be a ble device.

Related

Android application is being blocked from restarting by MARsPolicyManager

An Android function (APP A in the log) sent alerts to another application (APP B in the log).
We are facing one issue. APP B application is being blocked from restarting by MARsPolicyManager because of an autorun policy.
In Samsung S8, Smart Manager application is available. This application optimizes the device and kills the unnecessary background application from the device.
Below are the ADB logs:
05-30 01:03:33.481 1592 2291 D MARsPolicyManager: Blocked by Policy:2 -- Caller is not samsung!!
05-30 01:03:33.481 1592 2291 D MARsPolicyManager: Package: com.nielsen.appb, userid: 0, hostingType: provider is Restricted by policy: autorun(2) caller is: ProcessRecord{7da5e2d0 11579:com.nielsen.appa/u0a207}
05-30 01:03:33.482 1592 1654 I ActivityManager: Displayed com.nielsen.appa/md5ddf5d0d55652744930eac3d8d34aaa0c.SurveyPerform: +209ms
05-30 01:03:33.482 11579 11579 E ActivityThread: Failed to find provider info for com.nielsen.qct.contentprovider.EventsProvider
05-30 01:03:33.492 1592 2291 D EdgeLightingManager: isCallingUserSupported : callingUserId=0, mUserId=0, isDualAppId=false
05-30 01:03:33.492 1592 2291 D EdgeLightingManager: showForToast : packageName = com.nielsen.appa
05-30 01:03:33.492 1592 2291 D EdgeLightingClientManager: isAvailableEdgeLighting: condition=1 mCondition=3 mIsConnected=false0
05-30 01:03:33.492 1592 2291 D EdgeLightingPolicyManager: isAcceptableApplication: pkg=com.nielsen.appa
, range=512 , includeAllApp=false , userId=0 , infoRange=0 , infoCategory=0
05-30 01:03:33.492 1592 2291 D EdgeLightingManager: showForToast : return false by isAcceptableApplication.
When the app is force stopped all notifications are removed from the notification shade. Force stop / force killed also means the app can't receive any push notifications or any other Intents while the app is in this state.
The device is:
Samsung Galaxy S8
Model No-SM G9500
Android 8,9.
Processor- Snapdragon
This device model only available in the United States and China.
We need your support here. We have a couple of questions as well.
What the MARsPolicyManager is?
Is it something related to KNOX ?
How we can avoid this issue ?
Is this android specific ?

Movesense cannot be put into DFU mode because it does not connect via the Movesense Android App

I wanted to use new sample codes, which have been recently updated on BitBucket (plippo/c85e1ba - Updated Movesense Core Lib to version 0.3.1.105 - Updated Movesense sample applications to version 0.3.1.105).
The new code compiled and built properly. After successfully putting the movesense into DFU mode and uploading this firmware I was unable to read out the characteristics with the Movesense android app.
The Movesense is detected by the Android App as well as by other BLE tools (e.g. nRF connect app). The Movesense app gets stuck while connecting to the device. Hence I cannot readout anything, or put the device into DFU mode in order to reprogramm it. However, with the nRF connect app I am able to connect to it.
Comparing the previous and current versions of the embedded code, I noticed that the sample apps have been split. However in the app_root.yaml file the section
apis:
AccelerometerSample.*:
apiId: 100
defaultExecutionContext: PrimaryServices
HelloWorld.*:
apiId: 101
defaultExecutionContext: PrimaryServices
remained the same. I uploaded the sample app "accelerometer_app" where the HelloWorld Service is no longer available (compared to the old code). But is still listed in the yaml-file. I wonder if this is the reason why I cannot connect anymore with the Movesense App.
The last logged lines in the Android Monitor are the following ones
In the case of the old code, which is working:
05-24 15:52:05.350 29854-29854/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: connect() - device: C2:4B:A6:1E:73:AE, auto: false
05-24 15:52:05.350 29854-29854/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: registerApp()
05-24 15:52:05.350 29854-29854/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: registerApp() - UUID=7eec028c-3252-434f-9dcf-cc5ced36dd30
05-24 15:52:05.352 29854-29866/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5
05-24 15:52:05.414 29854-29854/com.movesense.android.sample_A_G_H.debug V/ViewRootImpl: Contents drawing finished : com.movesense.android.sample_A_G_H.debug/com.movesense.android.sample_A_G_H.MainActivity
05-24 15:52:07.548 29854-29881/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=5 device=C2:4B:A6:1E:73:AE
05-24 15:52:07.548 29854-29881/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: discoverServices() - device: C2:4B:A6:1E:73:AE
05-24 15:52:08.531 29854-29881/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: onSearchComplete() = Device=C2:4B:A6:1E:73:AE Status=0
05-24 15:52:08.531 29854-29881/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: setCharacteristicNotification() - uuid: 34802252-7185-4d5d-b431-630e7050e8f0 enable: true
05-24 15:52:08.563 29854-29928/com.movesense.android.sample_A_G_H.debug D/MovesenseAndroidWrapper: Connected device! serial ECKI5ABE47F3 address 10000001
05-24 15:52:08.563 29854-29928/com.movesense.android.sample_A_G_H.debug D/BleEnumeratorImpl: adding device 10000001
05-24 15:52:08.563 29854-29928/com.movesense.android.sample_A_G_H.debug D/BleEnumeratorImpl: getDevices 1
05-24 15:52:08.698 29854-30184/com.movesense.android.sample_A_G_H.debug D/RouteObserver: onNotify {"Serial": "ECKI5ABE47F3", "Type": "New"}
05-24 15:52:12.937 29854-30184/com.movesense.android.sample_A_G_H.debug D/addWhiteboardDevice: {"manufacturerName": "Suunto", "productName": "Movesense", "variant": "Unknown", "hwCompatibilityId": "C", "serial": "ECKI5ABE47F3", "pcbaSerial": "UNKNOWN", "sw": "0.3.0", "hw": "UNKNOW", "additionalVersionInfo": "UNKNOW", "addressInfo": "UNKNOW"}
05-24 15:52:13.022 29854-29854/com.movesense.android.sample_A_G_H.debug D/MainActivity: Connected to device: Peripheral [address: C2:4B:A6:1E:73:AE, name: Movesense ECKI5ABE47F3, RSSI: -43]
05-24 15:52:13.064 29854-29854/com.movesense.android.sample_A_G_H.debug I/Timeline: Timeline: Activity_launch_request id:com.movesense.android.sample_A_G_H.debug time:47413961
In the case of the new code, which is not working:
05-24 15:39:23.643 18160-18160/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: connect() - device: E8:E6:77:21:D1:45, auto: false
05-24 15:39:23.643 18160-18160/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: registerApp()
05-24 15:39:23.643 18160-18160/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: registerApp() - UUID=6c391ed2-8e59-42e5-9700-99758e9e8877
05-24 15:39:23.647 18160-18207/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5
05-24 15:39:23.771 18160-18160/com.movesense.android.sample_A_G_H.debug V/ViewRootImpl: Contents drawing finished : com.movesense.android.sample_A_G_H.debug/com.movesense.android.sample_A_G_H.MainActivity
05-24 15:39:27.577 18160-18171/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=5 device=E8:E6:77:21:D1:45
05-24 15:39:27.577 18160-18171/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: discoverServices() - device: E8:E6:77:21:D1:45
05-24 15:39:28.647 18160-18190/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: onSearchComplete() = Device=E8:E6:77:21:D1:45 Status=0
05-24 15:39:28.647 18160-18190/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: setCharacteristicNotification() - uuid: 34802252-7185-4d5d-b431-630e7050e8f0 enable: true
05-24 15:39:28.688 18160-18171/com.movesense.android.sample_A_G_H.debug D/MovesenseAndroidWrapper: Connected device! serial ECKID9F62D52 address 10000001
05-24 15:39:28.688 18160-18171/com.movesense.android.sample_A_G_H.debug D/BleEnumeratorImpl: adding device 10000001
05-24 15:39:28.688 18160-18171/com.movesense.android.sample_A_G_H.debug D/BleEnumeratorImpl: getDevices 1
It stops at the line D/BleEnumeratorImpl: getDevices 1.
This is an issue as I cannot put the movesense into DFU mode and reprogram it, so basically "it is broken" ;).
Question 1:
Are the services described in the yaml file the issue for this problem.
Question 2:
As I am able to see and connect to it via nRF connect App and be able to write data manually to the WRITE Characteristic, is there a way (command) which can be sent to the movesense, to put it into DFU mode.
Question 3: I cannot locate where the code gets stuck as I cannot track/follow BleEnumeratorImpl (see log lines). Where, in the entire android project is the BleEnumeratorImpl located?
I appreciate your help ))
EDIT: The new movesense-device-lib is out that fixes this BLE connectivity issue
This is a known issue that was causing random builds to get stuck in BLE connection phase. The issue is fixed in the next release that should be out either today or tomorrow. Since the bug prevents booting into DFU firmware update mode, the sensors can be only saved using programming jig (J-TAG cable). For those customers that do not have the jig, please contact the Movesense support via email (info (at) movesense.com) and you'll get new sensors to replace the bricked ones.
I'm really sorry about the inconvenience.
Full disclosure: I work for Movesense team
Please use new Android App. There is a working option for running DFU mode
(from Toolbar menu).
Soon all DFU operations will be included into this new example app.
Now after You will run DFU Mode You need to use Nordic DFU App.

React Native Android crashes when trying to debug in Chrome

I've got a React Native app that is working for iOS and am trying to get it up and running for Android. I have the app up and running in the emulator and I would like to debug it in Chrome to figure out some issues.
The problem occurs when I open up the in app dev tools and click the Debug in Chrome option the app crashes for a couple seconds and I get an alert message that says "Unfortunately MyApp has stopped." then right after that the app comes back up with the red screen and says "Unable to connect with remote debugger".
I believe I've set up everything as the directions said on this page.
Has anyone seen this kind of issue and if so is there a way to fix it?
Thanks!
Same problem here on Android. I've just started a project with react-native init and begun to follow the Facebook tutorial.
When I run the app without debugging, it works fine. If I enable Debug JS remotely, it crashes after 1 minute (doing nothing).
Testing on Samsung Galaxy S5, react-native-cli 0.2.0, react-native 0.32.1, Windows 7, Chrome 53.
In Android Studio I've found this stacktrace:
09-08 13:25:06.322 31080-3735/com.tutorialproject W/libc: pthread_create failed: couldn't allocate 1064960-byte stack: Out of memory
09-08 13:25:06.322 31080-3735/com.tutorialproject E/art: Throwing OutOfMemoryError "pthread_create (1040KB stack) failed: Try again"
09-08 13:25:06.332 31080-3735/com.tutorialproject E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
Process: com.tutorialproject, PID: 31080
java.lang.OutOfMemoryError: pthread_create (1040KB stack) failed: Try again
at java.lang.Thread.nativeCreate(Native Method)
at java.lang.Thread.start(Thread.java:1063)
at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:920)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1338)
at okhttp3.ConnectionPool.put(ConnectionPool.java:135)
at okhttp3.OkHttpClient$1.put(OkHttpClient.java:149)
at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:188)
at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:129)
at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:98)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:109)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:124)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:170)
at okhttp3.RealCall.access$100(RealCall.java:33)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:120)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
09-08 13:25:06.372 31080-31080/com.tutorialproject D/SensorManager: unregisterListener ::
09-08 13:25:06.852 31080-31185/com.tutorialproject W/unknown:React: Tried to enqueue runnable on already finished thread: 'native_modules... dropping Runnable.
09-08 13:25:06.852 31080-31185/com.tutorialproject W/MessageQueue: Handler (com.facebook.react.bridge.queue.MessageQueueThreadHandler) {246b7490} sending message to a Handler on a dead thread
java.lang.IllegalStateException: Handler (com.facebook.react.bridge.queue.MessageQueueThreadHandler) {246b7490} sending message to a Handler on a dead thread
at android.os.MessageQueue.enqueueMessage(MessageQueue.java:325)
at android.os.Handler.enqueueMessage(Handler.java:631)
at android.os.Handler.sendMessageAtTime(Handler.java:600)
at android.os.Handler.sendMessageDelayed(Handler.java:570)
at android.os.Handler.post(Handler.java:326)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl.runOnQueue(MessageQueueThreadImpl.java:61)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:145)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)
at java.lang.Thread.run(Thread.java:818)
09-08 13:25:06.862 31080-3792/com.tutorialproject W/ContextImpl: Failed to ensure directory: /storage/extSdCard/Android/data/com.tutorialproject/cache
09-08 13:25:11.362 31080-31088/com.tutorialproject W/art: Suspending all threads took: 5.930ms
It's a really simple project, with just a couple of text components, so I'm not doing any request. All the network communication is due the remotely debugging.
Since it's an OutOfMemory problem I've tried to add android:largeHeap="true" to Manifest.xml, but nothing changes. The app reaches the 32Mb consumption and dies.
I've modified the app, so it loads a component with an image 5000 times. With the debugging disabled, the app allocates up to 70Mb and works fine. I can scroll all over the screen and nothing crashes. When I enable the remote debugging, I works for a while, until it tries to allocate more memory and crashes again. I can start again the app with the debugging enabled, and it starts well, but again crashes after a while.
IMHO the React Native remote debugging feature has a problem for allocating new memory (and for some reason it consumes a lot of memory even when the app is stopped).
I had this problem as well (which is why I came across your post). Have you by any chance based your project on the React Native Material Kit Demo? I had, and was having exactly the same problem with crashing when launching devtools.
I've now rebuilt my project from the ground up using react-native init and the problem seems to have gone away.

Get this error when the card reader connect to my Host Card Emulation Service

I write the Host-Based Card Emulation(HCE) Application to do the mobile payment on my smartphone. I also use nfc-tools library to help me in coding both app on my phone and the reader. When I try to run the code on those 2 devices,both of them can connect together but it gives me the error as show belowed:
org.nfctools.scio.TerminalHandler getAvailableTerminal
INFO: Checking terminal: ACS ACR122 0
DEBUG: org.nfctools.spi.acs.AcsDirectChannelTag - command: FF00000004D44A0100
DEBUG: org.nfctools.spi.acs.AcsDirectChannelTag - response: D54B009000
javax.smartcardio.CardException: Cannot connect using direct, connection already established using Unknown protocol 0
at sun.security.smartcardio.TerminalImpl.connect(Unknown Source)
at HCECardScanner.run(HostCardEmulationCardScanner.java:18)
at Reader.run(Reader.java:622)
at Reader$11.actionPerformed(Reader.java:565)
Moreover, When I see in the log of the application,I found that My Application has a problem to start and run the Host-Based Card Emulation Service too.
06-28 14:18:30.083: I/ActivityManager(974): Start proc com.example.nfchcepayment for service com.example.nfchcepayment/.FirstApplet: pid=6068 uid=10268 gids={50268}
06-28 14:18:30.093: E/jdwp(6068): Failed sending reply to debugger: Broken pipe
06-28 14:18:30.093: D/dalvikvm(6068): Debugger has detached; object registry had 1 entries
06-28 14:18:30.103: I/dalvikvm(6068): Could not find method javacard.framework.ISOException.throwIt, referenced from method com.example.nfchcepayment.FirstApplet.processCommandApdu
Both 2 error are also related?

cant pair programmatically with BLE device

When I connect BLE device with my Nexus7 and Samsung Galaxy S3 with Android 4.3 , it connects and works fine.
When I try to connect programatically, it pairs(I can see logs and changing of the state to the paired).
But when I am trying connect and work with,there are different problem such as no service discovered and so on.
When I connect Samsung S3 with native android tools, it works, services is discovered and app works.
On Nexus 7 doesn't work even after native connection.
Logs that cause problems(At least I think so):
10-31 10:24:09.219: W/bt-l2cap(10778): L2CA_EnableUpdateBleConnParams - unknown BD_ADDR e0c79d649927
10-31 10:24:09.219: E/bt-btm(10778): btm_sec_disconnected - Clearing Pending flag
10-31 10:24:09.219: E/bt-btif(10778): Unknown conn ID: 3
10-31 10:24:09.219: E/bt-btif(10778): property type:3, len:0 is invalid
10-31 10:24:09.219: E/(10778): ### ASSERT : external/bluetooth/bluedroid/main/../btif/src/btif_dm.c line 1125 storing remote services failed (1) ###
10-31 10:24:09.219: E/BluetoothRemoteDevices(10778): devicePropertyChangedCallback: bdDevice: E0:C7:9D:64:99:27, value is empty for type: 3

Categories

Resources