Monthly Archives: April 2013

Bluetooth UUID – how to find it

So you have tried to connect to your Arduino using some BT modem from your Android device ? … and you couldn’t … well you probably used a wrong UUID here:
createRfcommSocketToServiceRecord(UUID.fromString(“fa87c0d0-afac-11de-8a39-0800200c9a66”))

For this case you should simple use this one: “00001101-0000-1000-8000-00805F9B34FB”

So how do you know this? From this table:

BASE_UUID 00000000-0000-1000-8000-00805F9B34FB
Service Class Name UUID Specification Allowed Usage
ServiceDiscoveryServerServiceClassID 0x1000 Bluetooth Core Specification Service Class
BrowseGroupDescriptorServiceClassID 0x1001 Bluetooth Core Specification Service Class
SerialPort 0x1101 Serial Port Profile (SPP)
NOTE: The example SDP record in SPP v1.0 does not include a BluetoothProfileDescriptorList attribute, but some implementations may also use this UUID for the Profile Identifier.
Service Class/ Profile
LANAccessUsingPPP 0x1102 LAN Access Profile
[DEPRECATED]
NOTE: Used as both Service Class Identifier and Profile Identifier.
Service Class/ Profile
DialupNetworking 0x1103 Dial-up Networking Profile (DUN)
NOTE: Used as both Service Class Identifier and Profile Identifier.
Service Class/ Profile
IrMCSync 0x1104 Synchronization Profile (SYNC)
NOTE: Used as both Service Class Identifier and Profile Identifier.
Service Class/ Profile
OBEXObjectPush 0x1105 Object Push Profile (OPP)
NOTE: Used as both Service Class Identifier and Profile.
Service Class/ Profile
OBEXFileTransfer 0x1106 File Transfer Profile (FTP)
NOTE: Used as both Service Class Identifier and Profile Identifier.
Service Class/ Profile
IrMCSyncCommand 0x1107 Synchronization Profile (SYNC)
Headset 0x1108 Headset Profile (HSP)
NOTE: Used as both Service Class Identifier and Profile Identifier.
Service Class/ Profile
CordlessTelephony 0x1109 Cordless Telephony Profile (CTP)
NOTE: Used as both Service Class Identifier and Profile Identifier.
[DEPRECATED]
Service Class/ Profile
AudioSource 0x110A Advanced Audio Distribution Profile (A2DP) Service Class
AudioSink 0x110B Advanced Audio Distribution Profile (A2DP) Service Class
A/V_RemoteControlTarget 0x110C Audio/Video Remote Control Profile (AVRCP) Service Class
AdvancedAudioDistribution 0x110D Advanced Audio Distribution Profile (A2DP) Profile
A/V_RemoteControl 0x110E Audio/Video Remote Control Profile (AVRCP)
NOTE: Used as both Service Class Identifier and Profile Identifier.
Service Class/ Profile
A/V_RemoteControlController 0x110F Audio/Video Remote Control Profile (AVRCP)
NOTE: The AVRCP specification v1.3 and later require that 0x110E also be included in the ServiceClassIDList before 0x110F for backwards compatibility.
Service Class
Intercom 0x1110 Intercom Profile (ICP)
NOTE: Used as both Service Class Identifier and Profile Identifier.
[DEPRECATED]
Service Class
Fax 0x1111 Fax Profile (FAX)
NOTE: Used as both Service Class Identifier and Profile Identifier.
[DEPRECATED]
Service Class
Headset – Audio Gateway (AG) 0x1112 Headset Profile (HSP) Service Class
WAP 0x1113 Interoperability Requirements for Bluetooth technology as a WAP, Bluetooth SIG [DEPRECATED] Service Class
WAP_CLIENT 0x1114 Interoperability Requirements for Bluetooth technology as a WAP, Bluetooth SIG [DEPRECATED] Service Class
PANU 0x1115 Personal Area Networking Profile (PAN)
NOTE: Used as both Service Class Identifier and Profile Identifier for PANU role.
Service Class / Profile
NAP 0x1116 Personal Area Networking Profile (PAN)
NOTE: Used as both Service Class Identifier and Profile Identifier for NAP role.
Service Class / Profile
GN 0x1117 Personal Area Networking Profile (PAN)
NOTE: Used as both Service Class Identifier and Profile Identifier for GN role.
Service Class / Profile
DirectPrinting 0x1118 Basic Printing Profile (BPP) Service Class
ReferencePrinting 0x1119 See Basic Printing Profile (BPP) Service Class
Basic Imaging Profile 0x111A Basic Imaging Profile (BIP) Profile
ImagingResponder 0x111B Basic Imaging Profile (BIP) Service Class
ImagingAutomaticArchive 0x111C Basic Imaging Profile (BIP) Service Class
ImagingReferencedObjects 0x111D Basic Imaging Profile (BIP) Service Class
Handsfree 0x111E Hands-Free Profile (HFP)
NOTE: Used as both Service Class Identifier and Profile Identifier.
Service Class / Profile
HandsfreeAudioGateway 0x111F Hands-free Profile (HFP) Service Class
DirectPrintingReferenceObjectsService 0x1120 Basic Printing Profile (BPP) Service Class
ReflectedUI 0x1121 Basic Printing Profile (BPP) Service Class
BasicPrinting 0x1122 Basic Printing Profile (BPP) Profile
PrintingStatus 0x1123 Basic Printing Profile (BPP) Service Class
HumanInterfaceDeviceService 0x1124 Human Interface Device (HID)
NOTE: Used as both Service Class Identifier and Profile Identifier.
Service Class / Profile
HardcopyCableReplacement 0x1125 Hardcopy Cable Replacement Profile (HCRP) Profile
HCR_Print 0x1126 Hardcopy Cable Replacement Profile (HCRP) Service Class
HCR_Scan 0x1127 Hardcopy Cable Replacement Profile (HCRP) Service Class
Common_ISDN_Access 0x1128 Common ISDN Access Profile (CIP)
NOTE: Used as both Service Class Identifier and Profile Identifier.
[DEPRECATED]
Service Class / Profile
SIM_Access 0x112D SIM Access Profile (SAP)
NOTE: Used as both Service Class Identifier and Profile Identifier.
Service Class / Profile
Phonebook Access – PCE 0x112E Phonebook Access Profile (PBAP) Service Class
Phonebook Access – PSE 0x112F Phonebook Access Profile (PBAP) Service Class
Phonebook Access 0x1130 Phonebook Access Profile (PBAP) Profile
Headset – HS 0x1131 Headset Profile (HSP)
NOTE: See erratum #3507.
0x1108 and 0x1203 should also be included in the ServiceClassIDList before 0x1131 for backwards compatibility.
Service Class
Message Access Server 0x1132 Message Access Profile (MAP) Service Class
Message Notification Server 0x1133 Message Access Profile (MAP) Service Class
Message Access Profile 0x1134 Message Access Profile (MAP) Profile
GNSS 0x1135 Global Navigation Satellite System Profile (GNSS) Profile
GNSS_Server 0x1136 Global Navigation Satellite System Profile (GNSS) Service Class
PnPInformation 0x1200 Device Identification (DID)
NOTE: Used as both Service Class Identifier and Profile Identifier.
Service Class / Profile
GenericNetworking 0x1201 N/A Service Class
GenericFileTransfer 0x1202 N/A Service Class
GenericAudio 0x1203 N/A Service Class
GenericTelephony 0x1204 N/A Service Class
UPNP_Service 0x1205 Enhanced Service Discovery Profile (ESDP) [DEPRECATED] Service Class
UPNP_IP_Service 0x1206 Enhanced Service Discovery Profile (ESDP) [DEPRECATED] Service Class
ESDP_UPNP_IP_PAN 0x1300 Enhanced Service Discovery Profile (ESDP) [DEPRECATED] Service Class
ESDP_UPNP_IP_LAP 0x1301 Enhanced Service Discovery Profile (ESDP)[DEPRECATED] Service Class
ESDP_UPNP_L2CAP 0x1302 Enhanced Service Discovery Profile (ESDP)[DEPRECATED] Service Class
VideoSource 0x1303 Video Distribution Profile (VDP) Service Class
VideoSink 0x1304 Video Distribution Profile (VDP) Service Class
VideoDistribution 0x1305 Video Distribution Profile (VDP) Service Class
HDP 0x1400 Health Device Profile Profile
HDP Source 0x1401 Health Device Profile (HDP) Service Class
HDP Sink 0x1402 Health Device Profile (HDP) Service Class
(Max value 0xFFFF)

More info can be found here: https://www.bluetooth.org/en-us/specification/assigned-numbers-overview/service-discovery

Enjoy 🙂

Windows Phone Developer Registration – phone name

Do you have an issue to register your windows phone 8 for development because it claims another device with the same name is already registered and you have to rename the device with a unique name. The message: “The device name is already in use by this account”.

Well the solution is simple – change the name, but how?

Trying to that from the device will be unsuccessful, you will just be able to see the name in About menu but not change it.

The actual solution is not that intuitive, – you need to change the name from the File Explorer.

Funny Windows it is!

enjoy 🙂

Install and use Arduino on Ubuntu

As in many other cases using Ubuntu Software Centre to install packages does not give you the most recent version and with Arduino Software is the same case.

So:

1) make sure you have java installed

2) download the newest arduino software from here: http://arduino.cc/en/Main/Software

3) install the compiler (gcc-avr) and the libraries (avr-libc) packages:

sudo apt-get install gcc-avr avr-libc

4) if you use the USB port to dialog, you should add yourself to the group ‘dialout’ in order to have write permissions on that port:

sudo usermod -aG dialout <your-user>

note that you need to log out the log in again or alternatively change the permissions on the port (more unsafe and has to be done every time you switch it on/off)

sudo chmod 666 /dev/ttyACM0 (for serial or /dev/ttyUSB0 for usb)

5) finally :

  • run ./arduino
  • select the board
  • select the port

Enjoy 🙂

Setup Ubuntu 13.04 raring for Android building

So what’s up with Ubuntu 13.04 raring and android building?
Basically the process is no different than 12.04 except that you need to uses the raring bins and of course correct oracle JDK ppa.

1) check that in your /etc/apt/sources.list you have

 deb http://archive.canonical.com/ubuntu raring partner
 deb-src http://archive.canonical.com/ubuntu raring partner
deb http://archive.canonical.com/ubuntu raring main
 deb-src http://archive.canonical.com/ubuntu raring main

not “lucid”

2) as I worote in http://blog.djodjo.org/?p=284
install Oracle JDK this way:

sudo add-apt-repository ppa:webupd8team/java
 sudo apt-get update && sudo apt-get install oracle-java6-installer

then as usual:

$ sudo apt-get install git gnupg flex bison gperf build-essential \
  zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \
  libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
  libgl1-mesa-dev g++-multilib mingw32 tofrodos \
  python-markdown libxml2-utils xsltproc zlib1g-dev:i386
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

and off you go 🙂

Install Oracle JDK on Ubuntu

This is a tutorial to manually install Oracle JDK on Ubuntu linux.

Hint: check bottom for the easiest solution.

Installing JDK6 using:

$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk

will no longer work as the package has been removed completely from the partner archive due to license issue,
see https://lists.ubuntu.com/archives/ubuntu-security-announce/2012-January/001554.html

You can install OpenJDK instead

sudo apt-get install openjdk-6-jdk

However building Android with openjdk may not always work smoothly. (http://groups.google.com/group/android-building/browse_thread/thread/0e24b41f11af36a1)

Here are the instruction how to install Oraclr JDK manually:

1) Download; the 32bit or 64bit Linux “compressed binary file” – it has a “.bin” file extension
jdk-{version}-linux-i586.bin
2)

chmod u+x jdk-6u32-linux-i586.bin

3)

 ./jdk-6u32-linux-i586.bin

4)

 sudo mv jdk1.6.0_32 /usr/lib/jvm/

5)

 sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.6.0_32/bin/java" 1
 sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.6.0_32/bin/javac" 1
sudo update-alternatives --install "/usr/lib/mozilla/plugins/libjavaplugin.so" "mozilla-javaplugin.so" "/usr/lib/jvm/jdk1.6.0_32/jre/lib/i386/libnpjp2.so" 1
6)
sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config mozilla-javaplugin.so
7) Check setup with 
java -version
sic@sic:~$ java -version
java version "1.6.0_32"
Java(TM) SE Runtime Environment (build 1.6.0_32-b05)
Java HotSpot(TM) Server VM (build 20.7-b02, mixed mode)

Alternatively you can do the following:

sudo add-apt-repository ppa:webupd8team/java

This will add the webupd8team PPA to your system for updated builds of Java 6/7/8 JDK (you need 6 for Android build) (https://launchpad.net/~webupd8team/+archive/java)
Then to install/update java you just need to :

 sudo apt-get update && sudo apt-get install oracle-java6-installer

enjoy 🙂

java overriding static method

Can we override a static method? – Yes, WE CAN! 🙂 but we don;t get the same effect as with non-static ones.

Static methods are not associated with an instance of a class. thus you cannot really override them, but:

class Main {
    public static void main(String args[]) {
            SuperClass a = new SubClass();
            SubClass b = new SubClass ();
            a.imStatic();
            b.imStatic();
            a.callStatic();
            b.callStatic();
    }
}
abstract class SuperClass {
    public static void imStatic() {
        System.out.println("I am superclass");
    }

    public void callStatic() {
        imStatic(); //no late binding here; always calls A.foo()
    }
}

class SubClass extends SuperClass {
    public static void imStatic() {
        System.out.println("I am subclass");
    }
}

the we get:

I am superclass
I am subclass
I am superclass
I am superclass

So what really matter is the type of the caller class, not the instance.

Android StatusBar and Notification View Summary

Brief overview of the history of the status bar and notification view(quick settings for 4.2+) in android.

Status Bar history:

1.5 – 2.2.2: com.android.server.status.StatusBarView

2.3 -2.3.7: com.android.systemui.statusbar.StatusBarView

4.0.1 – 4.2.2:             com.android.systemui.statusbar.phone.StatusBarWindowView(from 4.1.1) -> com.android.systemui.statusbar.phone.PhoneStatusBarView

there is also

com.android.systemui.statusbar.tablet.TabletStatusBarView

Notification +  Quick Settings View history:

1.5 – 2.2.2: com.android.server.status.StatusBarService.ExpandedDialog
2.3 – 2.3.7: com.android.systemui.statusbar.StatusBarService.ExpandedDialog
4.0.1 – 4.1.2 :         com.android.systemui.statusbar.phone.PhoneStatusBar.ExpandedDialog
4.2 – 4.2.2: com.android.systemui.statusbar.phone.NotificationPanelView  + com.android.systemui.statusbar.phone.SettingsPanelView
____________________
so basically before 4.2 the status bar and notification view were 2 different root views.
From 4.2 we have only com.android.systemui.statusbar.phone.StatusBarWindowView as a root view and then both notification and settings on different child views.
For non tablets it can be that we don’t have com.android.systemui.statusbar.phone.SettingsPanelView but on top of NotificationPanelView we can have:
com.android.systemui.statusbar.phone.QuickSettingsScrollView
->  com.android.systemui.statusbar.phone.QuickSettingsContainerView
->  com.android.systemui.statusbar.phone.QuickSettingsTileView (for every item)