简体   繁体   中英

How does the OBEX protocol look like?

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 

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM