0

I'm trying to exchange data between a mobile phone and a computer using bluetooth. I'd like to use OBEX for it. I have read OBEX_documentation and Wikipedia and tried to send a following package from a device 1 (computer):

const char package[] = 
/* Connect | 2B of length| OBEX Ver 1.0| Flag| Max Size               */    
      0x80,    0x00, 0x07,         0x10, 0x00, 2048>>8, 2048&0xFF};

and I would expect some kind of respond from a device 2 (cell phone) like:

const char res[]={0xA0 .... } //0xA0 == Success 

Even an error could would be great but I got blocked on recv(...).

It's implemented on Windows using winsock. I can pair and establish connection between these two. Somehow I don't understand how to handle the data transfer. I have read the theory but it let me down.

This is how I send and receive:

if (send(s, package, sizeof(package), 0) == SOCKET_ERROR)
{
  auto error = WSAGetLastError();
  if (error != WSAEWOULDBLOCK) 
  {
    std::cout << "Unable to send packet ";
  }
}

auto receiveByteCount = recv(s, buff, 1024, 0); // blocking 
user
  • 95
  • 1
  • 9
  • Which service are you trying to connect? Not all services are OBEX based. – Mike Petrichenko Mar 03 '21 at 10:24
  • I know. I want to get a phonebook (vcard) and related things – user Mar 03 '21 at 10:25
  • Depending on cell it may have different services for such purpose. In common way you have to connect to PBAP. It requires additional parameters in Open Session command. Refer to PBAP Profile description. – Mike Petrichenko Mar 03 '21 at 10:31
  • where can I find a valid description? It seems like it's a secret knowladge... – user Mar 03 '21 at 10:41
  • 1
    https://www.bluetooth.com/specifications/specs/ – Mike Petrichenko Mar 03 '21 at 10:48
  • thx :) I have already implemented sth like that: const char package[] = { 0x80, // connect 0x1A>>8, // size 0x1A&0xFF, // size 0x10, // ver 0x00, // flag 2048>>8, // max size 2048&0xFF, // max size 0x46, // target opcode 0x13>>8, // target size 0x13&0xFF, // target size 0x79, 0x61, 0x35, 0xF0, 0xF0, 0xC5, 0x11, 0xD8, 0x09, 0x66, 0x08, 0x00, 0x20, 0x0C, 0x9A, 0x66 //Target }; But all I got is: \r\nERROR\n\r – user Mar 03 '21 at 11:52
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/229447/discussion-between-user-and-mike-petrichenko). – user Mar 03 '21 at 12:05
  • Back to my first question: which servuice do you connect to? – Mike Petrichenko Mar 03 '21 at 12:54
  • PSE - GUID{ (uint32_t)0x0000112F, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB } – user Mar 03 '21 at 12:57
  • CRLF ERROR CRLF - is the DUN answer (modem). Show your connection code. – Mike Petrichenko Mar 03 '21 at 13:04
  • posted on the chat – user Mar 03 '21 at 13:09

1 Answers1

0

The PBAP is describe here (search for PBAP). The link was given by @Mike Petrichenko The other helpfull post can be found here.

user
  • 95
  • 1
  • 9