Bluetooth (ObexFTP) file transfer timeout on Linux

Dear Reader,

Lately i have been experiencing a weird issue on my Linux box of Zenwalk 7.8. I am using blueman app here to transfer the files.

Strange part was, i was able to send files to my linux box (Laptop) from my mobile device, but not the other way around. This always irked me a bit but did not bother much as i hardly use the bluetooth. But today, i decided to do a bit of research (logs and google) on this and i happen to run some diagnosis.

First, via blueman i paired the devices. Trying to send the file from box to mobile device, it reported time out error. Looking at the dmesg logs, it turned out nothing much useful.

Next, i went on to see if the device has been properly recognized by the bluetooth service. So ran few commands as root (sudo) user listed below:

bash-4.3# hcitool dev
hci0    3C:XX:XX:XX:XX:XX

The MAC address printed from the above command is the bluetooth chip on my laptop/desktop.

To know HCI0 bus info, you can run command:

bash-4.3# hciconfig dev
hci0:    Type: BR/EDR  Bus: USB
BD Address: 3C:XX:XX:XX:XX:XX  ACL MTU: 1021:8  SCO MTU: 64:1
RX bytes:15273 acl:156 sco:0 events:648 errors:0
TX bytes:109775 acl:248 sco:0 commands:419 errors:0

Once the device is detected, next i ran another command to make the device (BUS) up, in case it hasn’t.

bash-4.3# hciconfig hci0 up

The above command doesn’t print out any return lines. All is well so far.

Next i wanted to know if the mobile device is in the radar, i need to scan it:

bash-4.3# hcitool scan
Scanning …
7C:XX:XX:XX:XX:XX    zenwalker

Note the MAC address printed above is of the mobile device.

Then i wanted to connect the hcitool to mobile device:

bash-4.3# hcitool cc 7C:XX:XX:XX:XX:XX

Everything seems to be on track. Now, since the blueman is unable to transfer the file to my mobile device (Hint: Make sure your firewall isn’t blocking connection), its of no use using it further. So i tried via obexftp tool, since the blueman app uses the same tool underneath.

bash-4.3# obexftp -b 7C:XX:XX:XX:XX:XX -p /home/zenwalker/Pictures/abc.jpg

I tried sending a pic to my mobile device via above command, but it returned me some errors:

Connecting…failed: connect
Tried to connect for 3ms
error on connect(): Invalid argument

Further investigation revealed that, i need to explicitly mentioned the channel to which it should communicate. Usually this shall be figured by itself, but some times some mobile devices act crazy or the tool here itself is not bullet proof.

So what the heck is this channel or where do i get it?😮

Run this command:

bash-4.3# sdptool browse 7C:XX:XX:XX:XX:XX

This command outputs following result:

Service RecHandle: 0x10000
Service Class ID List:
“Generic Attribute” (0x1801)
Protocol Descriptor List:
“L2CAP” (0x0100)
PSM: 31
“ATT” (0x0007)
uint16: 0x1
uint16: 0x5


Service RecHandle: 0x10001
Service Class ID List:
“” (0x1800)
Protocol Descriptor List:
“L2CAP” (0x0100)
PSM: 31
“ATT” (0x0007)
uint16: 0x14
uint16: 0x1e


Service Name: Headset Gateway
Service RecHandle: 0x10002
Service Class ID List:
“Headset Audio Gateway” (0x1112)
“Generic Audio” (0x1203)
Protocol Descriptor List:
“L2CAP” (0x0100)
“RFCOMM” (0x0003)
Channel: 2
Profile Descriptor List:
“Headset” (0x1108)
Version: 0x0102


Service Name: Handsfree Gateway
Service RecHandle: 0x10003
Service Class ID List:
“Handsfree Audio Gateway” (0x111f)
“Generic Audio” (0x1203)
Protocol Descriptor List:
“L2CAP” (0x0100)
“RFCOMM” (0x0003)
Channel: 3
Profile Descriptor List:
“Handsfree” (0x111e)
Version: 0x0106


Service Name: AV Remote Control Target
Service RecHandle: 0x10004
Service Class ID List:
“AV Remote Target” (0x110c)
Protocol Descriptor List:
“L2CAP” (0x0100)
PSM: 23
“AVCTP” (0x0017)
uint16: 0x102
Profile Descriptor List:
“AV Remote” (0x110e)
Version: 0x0103


Service Name: Advanced Audio
Service RecHandle: 0x10005
Service Class ID List:
“Audio Source” (0x110a)
Protocol Descriptor List:
“L2CAP” (0x0100)
PSM: 25
“AVDTP” (0x0019)
uint16: 0x102
Profile Descriptor List:
“Advanced Audio” (0x110d)
Version: 0x0102


Service Name: Android Network Access Point
Service Description: NAP
Service RecHandle: 0x10006
Service Class ID List:
“Network Access Point” (0x1116)
Protocol Descriptor List:
“L2CAP” (0x0100)
PSM: 15
“BNEP” (0x000f)
Version: 0x0100
SEQ8: 0 6
Language Base Attr List:
code_ISO639: 0x656e
encoding:    0x6a
base_offset: 0x100
Profile Descriptor List:
“Network Access Point” (0x1116)
Version: 0x0100


Service Name: OBEX Phonebook Access Server
Service RecHandle: 0x10008
Service Class ID List:
“Phonebook Access – PSE” (0x112f)
Protocol Descriptor List:
“L2CAP” (0x0100)
“RFCOMM” (0x0003)
Channel: 19
“OBEX” (0x0008)
Profile Descriptor List:
“Phonebook Access” (0x1130)
Version: 0x0101


Service Name: OBEX Object Push
Service RecHandle: 0x10009
Service Class ID List:
  “OBEX Object Push” (0x1105)
Protocol Descriptor List:
  “L2CAP” (0x0100)
  “RFCOMM” (0x0003)
    Channel: 12
  “OBEX” (0x0008)
Profile Descriptor List:
  “OBEX Object Push” (0x1105)
    Version: 0x0100

Above is a series of channels available in my mobile for many types of communications. Search in your output for “OBEX file transfer” or “OBEX object push” or similar text under service name section (highlighted in RED), the rest all is gibberish related to this subject. Take a note of the Channel value. In my case its 12, for Nokia phones it could be 11 and for some other phones it could be something else.

Lets try again to transfer the file by explicitly stating the channel:

bash-4.3# obexftp -b 7C:XX:XX:XX:XX:XX  -B 12 -p /home/zenwalker/Pictures/abc.jpg

But again dead-end with errors:

Connecting..\failed: send UUID
Tried to connect for 120ms
error on connect(): Success
Still trying to connect

Back to drawing board😦. Further investigation revealed that i should force the obexftp tool to ignore UUID (hint taken from error message😀 )

So now, lets use options “-U NONE” for the above command:

bash-4.3# obexftp -b 7C:XX:XX:XX:XX:XX  -B 12  -U NONE -p /home/zenwalker/Pictures/abc.jpg
Suppressing FBS.
Tried to connect for 112ms
Sending “/home/zenwalker/Pictures/abc.jpg”…-done

Yuppie, at last success😀

Next step is to add these options into the bluetooth config files to make blueman work successfully. That’s for another blog post😉

Thanks, hope it helps

Generic method to avoid long IF clauses

Dear Reader,

Recently at work, i was working with a library which had lot of properties wherein they must be verified for its Truth value before exporting or importing respective attributes to file or back to UI respectively.

Basically, the raw code initially looked roughly like below:

void ExampleMethod() {
SomeType type = new SomeType();

if (type.HasValue1)
  //Export Value1
if (type.HasValue2)
  //Export Value2
if (type.HasValue3)
  //Export Value3
if (type.HasValue4)
  //Export Value4
if (type.HasValue5)
  //Export Value5
if (type.HasValue6)
  //Export Value6
if (type.HasValue7)
  //Export Value7
if (type.HasValue8)
  //Export Value8
if (type.HasValue9)
  //Export Value9
if (type.HasValue10)
  //Export Value10
if (type.HasValue11)
  //Export Value11
if (type.HasValue12)
  //Export Value12

if (type.HasValue25)
  //Export Value25

The above case got repetitive at many places for other types in the same library based on level of their appearance in the UI viz. tree level node. The body of the if-clause all over the place remained same i.e 1 – Check for Truth, 2 – if success, Add to some final list for exporting/importing if not already present.

The method complexity in some cases went over 20 which was getting really gruesome to me. Finally, i decided to refactor the code to reduce not just the complexity but also find a unified solution for other basic types if need be.

Struck to me are 2 possible yet simple solutions yet satisfying the required criteria.

Solution 1: To use the Dictionary<Func< T >, SomeType>, but the body of all those if clauses required another 3rd parameter which hindered me to not opt the dictionary since Dictionary can’t have more than Key : Value pair thus making me to add dictionary inside dictionary which is not only complex in readability aspects but also Value dictionary may not be unique as well. So i had to discard this solution.

Solution 2: To make use of Generic Methods with delegates via lambda expression. This proved to be a working solution in this case yet very simple and effective.

void CheckAndDoSomething < T > (Func< T > property, object Value,
object otherValue) where T: struct
  Type t = typeof(T);
  if (t is bool && property())
     //Do some thing with Value and OtherValue

void ExampleMethod()
  SomeType type = new SomeType();
CheckAndDoSomething(() => type.HasValue1,value0, otherValue0);
CheckAndDoSomething(() => type.HasValue2,value1, otherValue1);
CheckAndDoSomething(() => type.HasValue3,value2, otherValue2);


Hope it helps,

Xiaomi Redmi File transferring with Linux.

Explained in simple steps:

1. You need ADB (Android Bridge) tools. Just paste this in your terminal as SU bash <(curl…/nexus…/master/
2. The nexus tool downloads and install appropriate version of ADB for your Linux box. Wait few minutes.
3. As SU, execute => adb start-server
4. Enable USB debugging on ur RedMe and connect to your linux box.
5. Still as SU, execute => adb devices. It shall list your android device.
6. If you get “????????? no permission” as output from step 5, then you have not started adb service as SU and other commands too.
7. Once you got things straight. Now copy files from phone to pc via “adb pull” or paste to phone via “adb push”.
8. In my case, i wanted to copy entire DIR onto phone. So i did just “adb push /PC_DIR_Path/DIR_TO_COPY /PHONE/DIR_COPIED
9. To know the path on your phone, just use any file explorer and get the details of path. In my case it was /storage/sdcard1/Music. It could be different on yours.

GOA: Dream trip come true!

The background story goes like 4 years back, where in i had been waiting and planning to visit the exotic place GOA. Every time a plan is made, some or the other reasons the folks used to back out or some other problems. Yes it took 4 years for this damn plan to get executed. We bangloreans do really have lousy busy life…😐

The start of the new year, did bring in some good luck for me:) The plan got executed. We went for 5 beaches : Vagator, calangute, anjuna, baga and condolim.

The route suggested to me was : Belgaum – amboli ghat – sawantwadi – goa. Onward journey we took Belgaum – VTU – kankumbi – surla (chorla ghat) – mapusa by inquiring with local tea shop guys at Belgaum. To our surprise, this route was much much better than sawantwadi route which was our return journey.

On this route there is no lousy RTO check post or police trouble and even the goa police check post also doesnt bother much to the travellers. I rekon this route is mostly used by the local folks than others. The traffic on this route was very very minimal. The whole Chorla ghat section is around 50kms ODD. The road conditions on this ghat is brand new and awesome. I loved driving in this section compared to amboli in all senses.

Let pics do the talk…. First trip i did not care to take enough pics…

Onward journey

The onward journey road was soo good, i loved driving till Goa from Chitradurga. And the fact that its my babez (Punto), it just rushes out all the adrenaline you need:)

Apparently security did not let us in to see VTU upclose as no lights were on.

The early morning pit stop after Chorla Ghat section drive.

Palacete Rodrigues: The lousy hotel we stayed at Anjuna beach. As per website, this place suppose (pics wise) to have beautiful rooms, big pool and good food restaurant. Pool size is soo small that you hardly can toss around. The rooms size of 4 were lousy, the cots were bad, bed spreads dirty. The food was bad or next to horrible. I personally would rate this place 1. I heard that the couples suite costing 6+k/day is good but the ones which we stayed costed 3k, was not

Lovely view from Agoda Fort

Thats the agoda forts light house.

Sinquerim Rocks, Condolim beach. Beware there is not enough parking space here.

If lit well, Suvarna vidhana soudha should have been visible😦

Curries Bar & Restaurant : Very nice place outside calangute beach area and very nice food, good prices and rooms available too. I recommend this place for any body. They have couples bedroom, family (10 member) bedrooms too and very good prices. Foods are very reasonable prices too. We loved the food though with good quality. This guy Mahesh does very clean business. Infact our next visit to goa will def choose this place.
Address: Porba Vaddo, Calangute, Bardex, Goa 403 517. Email: Ph: 9822580711

Loved the food and stuffs here.

Decision matrix implementation in C#

Dear Reader,

Yesterday i faced a problem where the combinations possibilities were many and i had to implement code for this problem. Obvious solution is to implement If – else ladder. But i absolute hate this solution because the combination were around 5C3. The combination data was about behavior aspect of a scenario. Next solution is to use Switch block. But this solution involves inner switch combinations. So down the line it gets more complicated.

Next solution was to go for dictionary. But the problem with dictionary is the key uniqueness. In my case, most of the keys were not unique. So either i had to customize the dictionary behavior (List of KeyValuePair) or go for some thing else. The earlier will lead to writing alot of code for small problem and involves more cost factor in terms of development time and testing effort.  Idea rejected.

Then i suddenly remembered to make use of Decision table. So googling a bit to learn more about decision matrix, this is what i could implement which is not just extensible but also easy to understand and easy to add/modify later on. No need to change in the actual code (finding the combo) unless the way to look up methodology changes.

Sample code:


At line 27, i am here searching for a combination key of “Condition3” AND “ASC”, then get the result from the matrix. Line 31, have used FirstOrDefault() than First() to avoid exception when result is not found.

Hope it helps,

Linux: gdm (XServer) Crash with error dgm_slave_xioerror_handler

Dear Reader,

Recently upgrading XServer, GDM with many other packages, suddenly launching gthumb started to crash the XServer. Resulting me to pop back into login window. This happen all the time consistently. At first i thought it was the problem with Gthumb application itself. Tracing back the upgrade log, i did not find itself getting upgraded in a long time. So next step was to see its dependent packages. From the .dep file in the FTP server, i saw there was huge number of packages on which gthumb is dependent on. So going this way in finding which was upgraded and which was is not really a good choice. So i immediately started to look into kernel messages aka dmesg and system logs files.

I did not find much information in dmesg. Next digging further into /var/log/syslog file prompted me to this error line:

gdm-binary[5197]: WARNING: gdm_slave_xioerror_handler: Fatal X error – Restarting :0

This line itself was enough to give me assurance that it was caused by the GDM and not any gtumb or related applications. Now GDM package involves even Xserver packages too. So googling was the only left out solution. As per google, there were many suggestions given i.e Reinstalling xserver packages, editing xorg.conf file, etc. None of them was much helpful.

Next is to look at the video driver side. So looked at the Nvidia Linux drivers page, found that a long stable version is released which is 319.49. I had 319.23. The new version release notes also mentions about a bug fix on Xserver/gdm crash. So immediately went for upgrading the driver.
Voila, it worked. Now i can use gthumb, gimp and other applications which were causing the crash.
Hope it helps…


My Car Buying learning’s

Dear All,

Below is the learning’s, which i wish to write about coz they helped me in making sure my booking, buying, delivery process went smooth and nothing oh shit moments. Hope it will help future buyers.

Of course the SA was really helpful to me here.

These are my personal learning’s based on my seeking information from fellow TFI folks, extensive reading of TFI threads, mistakes and observations. Feel free to pick it up if you agree so (Not in correct order).

  • Always carry pen and paper: Helpful in taking notes than later “Oh Shit forgot that” moments.
  • When booking, always ask for a clear cut brake-up of charges (detailly) and written on a paper by the SA. Keep and carry that with you till PDI day.
  • Make a note of all the agreements (prices, goodies, etc.) said by the SA.
  • Know your car and its features clearly and good.
  • Read the datasheet of the model which you have chosen. Remember all the things written in the datasheet. SA might throw you some bones here.
  • Keep mentioning about TFI to SA.
  • Say youll be writing review reports, etc. @TFI. Quite helpful.
  • See if you get a gap to meet the boss of SA, again mention about TFI to him as well.
  • Dont let SA’s fool you easily. Always gather more information about the car or FIAT or prices, etc. TFI is really good source for that.
  • Try to haggle as much as possible. Aim for goodies/freebies.
  • Aim/Demand for all OEM (FIAT) made freebies from dealer for free. (Thanks Neeraj for reminding me and helping me over calls)
  • Make sure you thank SA as and when required in-front his boss or his colleagues, but please mean it. Happy SA = Happy You.
  • If SA doesnt call often and gives you updates (self initiative) , that means he isnt interested much in your buying. After your booking, give it couple of days as he/she has agreed to give you updates. Later on if no news, then he/She just not into you. Find other ways to deal. (Neeraj faced this problem)
  • Dont be rude or demanding unless you know SA is lethargic.
  • On PDI day, carry all the papers, PDI checklist with you. Be kind in requesting/notifying your SA for his time for PDI. If SA asks for a time change, try to adjust. Always Win:Win works better.
  • Do extensive PDI on your car. If car seemed to have dirt here and there, make a kind request with SA to get it washed. Yard has all facilities. Mention well ahead to SA that youll be doing extensive PDI, so its bound to take more time.
  • Carry USB stick (songs) and an Audio CD with you.
  • See if your Phone Bluetooth works with Cars Blue and Me.
  • Do note down all stuffs (Not working) in the car.
  • If you are getting Parking sensors, then ask for OEM made (if you wish), Car cover again OEM.
  • If car data sheet mentions Remote for HU. Then ask for it. Note it down to get it when taking delivery.
  • On delivery day, carry a good gift for the SA. Need not to be expensive. Worth of 1K is good.
  • Carry Sweets to give it all there, on weekdays less people will be present compared to weekend. At KHT i saw atleast 20 peeps in weekend and hardly 10 on weekdays in my 4 time visits.
  • Re-do PDI checks roughly. Ask SA to explain all the features of the car.
  • Ask as many doubts as possible.
  • Ask SA to load all contacts of your phone to cars blue and me. Some mobiles wont support this, i was informed by my SA.
  • Check voice commands and try out all keys on ur dashboard, steering mounted keys for working nature as per PDI check list.
  • Go for a short TD and observe for rattles, alignments, etc.
  • Before documentation process, make sure SA gets all the accessories as agreed is on the table. If not, remind him.
  • Before signing any official documents, check for
    1) Original Car Documents
    2) Warranty cards of car, parking sensors
    3) Key code card
    4) Battery warranty card
    5) Extended warranty card
    6) Original Tax Receipt a MUST.
    7) Insurance papers
    8) Original Invoice
    9) Fuel Coupon (If any)
    10) Other documents if any.
  • Get all above documents sealed
  • Request for Absolute Mud flaps (if agreed)
  • Request for Floor mats
  • Once all documentation is done, key shall be handed over to you.
  • Give the honor of giving him the Gift and thank him.
  • Distribute sweets starting off with the SA.
  • They shall take you to the car to give a formal handover again. Carry camera to capture this moments.
  • Thank every one and request for their continuous support in future and say you are really happy and going to write good review about them, but mean it
  • Fill the fuel.
  • Drive home safely.