Monday, July 29, 2013

Android Application Bluetooth Low Energy Scanner

After installing the Android 4.3 on Nexus-4, one can write the Bluetooth Low Energy (BLE) programs on Android platform. As still no official samples are available from LG/Google on the SDK samples, I tried to dig through available the Java-docs for new SDK and write  an Android-App for scanning all BLE devices available in vicinity.

To use this application, we need following:

  • Any Android with 4.3 installed and have BLE HW support ( that means the mobile phone should support Bluetooth 4.0)
  • For getting list of scanned devices, we have two options:
    • Have real BLE devices (like BLE dongles, chips, SoC, etc)
      • We need to have a firmware image that allows us to start the discoverability on the device.
    • Have another Android 4.3 phone with BLE enabled and discovery enabled

I have TI's CC2540DK-MINI development kit  and NordicSemi's   nRF51822 Development kit. TI's kit comes with a KeyFrob and USB-based-BLE-devices and USB-based firmware loader.  For current project, I am using TI's kit's KeyFrob as my BLE device (that I am scanning from Android phone).

I have loaded the project code to the  project site.
You can try the same application using the Android application download link

Here is screen shot

Sunday, July 28, 2013

New Android 4.3 Manual Update on Nexus-4 does not contain OpenCL support

After successful update of Android 4.3 on Nexus-4 phone, I have found that my OpenCL Android applications are not running in system. After some initial lookup/debug of problem using:

  • adb logcat  is indicating that libOpenCL is not loaded
  • abd shell ls -l /system/lib/ is not returning any entries
So it seems that google/LG will take some more time to make the OpenCL work on Android 4.3

Update of Nexus 4 with Android 4.3

As official OTA update for Android 4.3  from google is not still available on Nexus-4 (4.3 is released on 24-Jul-2013), I thought that let me try manual (risky approach & could brick phone) uploading using various following links:
Disclaimer: Please note that normally one should wait for OTA updates from Google. This manual approach is risk prone and may brick your device. If you try this approach, please keep in mind that you may brick your device & I am not responsible if any thing happens to your device :)

BTW using this procedure, all old information/application in phone will be still intact (unless otherwise something extra things were done).

  • You have non rooted Nexus 4 and it is in Android version 4.2.2 and you have PC/Laptop with Windows-XP-SP3 (it may work with other latest window versions, but I have not worked with them for this operation)
  • You have latest Android SDK tools.
    • Your adb should have following version:
      • adb version  : Android Debug Bridge version 1.0.31
      • Note: adb help will not show sideload command while issuing adb help. So please ensure that we have above adb version. The adb sideload command will work when the phone is in recovery mode
  • You have properly installed windows drivers on computer so that you can see devices from 'adb devices'
  • You have downloaded the Android 4.3.3 release zip file for Nexus-4 (stock with no ROM modiifcations)  from following link . If you other devices other than Nexus-4, please check for the update zip at that site.
    • After download rename the file to
    • Length of file:  177,524,837 , MD5: a62d34fef0fda5a512ffdc87b59ed9d4
  • While doing update, you may need to add extra USB device drivers for adb sideload
    • Add following entries in your Drive:\opt\Android\android-sdk\extras\google\usb_driver\android_winusb.inf
      • In section  [Google.NTx86]
        • %CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_D001
      • In Section [Google.NTamd64]
        • %CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_D001
    • You need to do this in case when your adb sideload says no devices found. Above USB VID(Vendor ID) and PID( Product ID) are for Nexus 4. 
    • If your device is not Nexus-4, the VID & PID might change and you get them via (please ensure that you are connected to PC via USB cable and the phone is in recovery mode -- go to that mode by: adb  reboot bootloader & procedure below):
      • My Computer -- Manage -- Device Manager -- Other Devices -- Nexus 4 -- Properties -- USB VID & PID from Combox over there
Update procedure
  • Goto boot recovery mode:
    • Without SDK tools:
      • Stop Android phone
      • Press Volume-UP and Volume-Down and Power buttons simultaneously
    • With ADB
      • adb  reboot bootloader
  • Use Volume buttons to select 'Recovery Mode'
    • Use power button to select the operation
  • Phone should show Android Icon with Exclamation mark. Press Volume-UP and Power buttons 
  • Use Volume buttons to select 'Update from ADB'
    • Use power button to select the operation
  • Then it will show load using adb sideload
    • Ensure that you have configured Nexus 4 Recovery mode USB drivers as mentioned above for your Nexus 4 device
  • Then from PC issue following command
    • adb sideload c:\
    • It will take few minutes for doing updates (if everything is went fine). 
Hope this helps who wants to get 4.3.3 updates and can't wait till google OTA update comes officially and want to take risk :)