0

I would like to implement a file browser via Bluetooth. I'm already able to connect and talk to an other computer. I would like to be able to list all available files under a specific path. I know I have to do as follows:

  1. Connect - to establish connection between 2 computers via BT
  2. SetPath - to choose a path I want
  3. Get - to get the list

I got stuck on 2. My data frame looks like that:

const char Setpath[] = {
 0x85, // SetPath
 0x00,0x15,// size of the msg
 0x02, // flag
 0x00, // const
 0xcb, // HI for ConnectionId header
 0x00,0x00,0x00,buff[11], // Connection ID
 0x01, // HI for Name header
 0x00,0x0B, // length of Name header
 0x2f,0x68,0x6f,0x6d,0x65,0x2f,0x00,0x00,  // /home/
  };

each time I send that packate, I got: C4 00 03, which means the file doesn't exsit.

So, how should the path look like to browse through Linux files?

user
  • 95
  • 1
  • 9

1 Answers1

0

OBEX SetPath Command allows only for setting the current folder to the root, parent or a child folder. For example in order to set the folder to "/home", it would be necessary to apply SetPath twice: the first is necessary to change into "root" (although I think C4 00 03 indicates you are there already) and the second is necessary to change into "home". To put it another way: you can't do a path as you cannot use slash (/) anywhere in the information

ukBaz
  • 6,985
  • 2
  • 8
  • 31
  • ok. Interesting, I did't know that. Where I can find these informaton? thank you. What I've just done, was to set a path to root, and then to get the list of folders/files from the root level... If i'm not mistaken, a root folder from bt perspective is the same as "cd /" on Linux (if my devices run on Linux ). The answer is wierd: I'm not a Chineese and I have no folders/files like that under "cd /" on my Linux. – user Mar 05 '21 at 11:26
  • The two roots are probably not the same thing. It has been a while since I've done anything with OBEX but I seem to remember that I had to specify the OBEX root when starting the daemon. On Linux I have tended to use the BlueZ D-Bus API documented at https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/obex-api.txt – ukBaz Mar 05 '21 at 11:44
  • is it documented somewhere on Obex? I cannot find it in the official docs. It would be great to know how to change it as my client is a windows based device... – user Mar 05 '21 at 12:27
  • Is this what you are looking for: https://www.irda.org/standards/pubs/OBEX13.pdf ? – ukBaz Mar 05 '21 at 12:34
  • thank you but unfortunately no, I have read it already. It's something between detailed and generic descirption. Not much about the root topic itself. – user Mar 05 '21 at 12:37
  • 1
    The issue with the unrecognized folder names, that data would have come across as bytes, so could it be an encoding issue? for example `'⽨潭支畳敲⽄敳歴'.encode('utf-16-be')` = `b'/home/user/Deskt'` – ukBaz Mar 05 '21 at 13:09
  • not so sure, but maybe. I'll check that. thank you :) – user Mar 05 '21 at 13:32
  • most likely. I have created a new folder in the root folder. The name is totally messed up but the creation time is relevant. So it looks like the folder names are crusched in a way, because the rest of wording in xml file looks perfectly fine. many thx @ukBaz :) – user Mar 05 '21 at 13:50
  • I managed to make a final step towards it. So the ⼯桯浥⼯.encode(utf-16-be) = b'//home//'' – user Mar 09 '21 at 10:49