Export (0) Print
Expand All

Server Support (Windows Embedded CE 6.0)

1/6/2010

The OBEX server is an extensible OS service that facilitates information exchange using Bluetooth or the IrOBEX 1.2 protocol. It acts as a protocol translator and forwards packets to the appropriate transport layer.

The server, itself, is implemented as Obexsrvr.dll, a service/device driver capable of running in the context of Device.exe or Services.exe. It supports two types of networking media: Bluetooth and IrDA. Each can be individually disabled. Network transport extensions are not supported.

Packet interpretation and request servicing is deferred to OBEX extensions, supplied by original equipment manufacturers (OEMs) and independent software vendors (ISVs).

The following extensions are included with Windows Embedded CE:

  • Obexinbx.dll
    This library offers default inbox server extensions that support object pushing and pulling using MIME types.
  • Obexfile.dll
    This library offers a browsable file exchange service that supports object pushing and pulling on a local file system.
    Ee494510.note(en-US,WinEmbedded.60).gifNote:
    The OBEX server does not support command extensions. Received packets must fall under Connect, Disconnect, Put, Get, Abort, or Setpath, which are defined in the IrOBEX 1.2 Specification.

You cannot open a COM port that is opened by Obex because Obex has exclusive control of the port. The following sample code shows how to programmatically disable Obex so that you can open the port.

#include <windows.h>
#include <service.h>
HRESULT OBEXIOCTL(DWORD dwIOCTL)
{
    HANDLE hService;
    BOOL fRet;
    hService = CreateFile(L"OBX0:",GENERIC_READ|GENERIC_WRITE,0,
                          NULL,OPEN_EXISTING,0,NULL);
    if (INVALID_HANDLE_VALUE == hService)
        return FALSE;
    fRet = DeviceIoControl(hService,dwIOCTL,0,0,0,0,NULL,0);
    CloseHandle(hService);
    return (0 == fRet)?E_FAIL:S_OK;
}
DWORD OBEXQuery() 
{
    HANDLE hService;
    BOOL fRet;
    DWORD dwStatus;
    hService = CreateFile(L"OBX0:",GENERIC_READ|GENERIC_WRITE,0,
                          NULL,OPEN_EXISTING,0,NULL);
    if (INVALID_HANDLE_VALUE == hService)
        return FALSE;
    fRet = DeviceIoControl(hService,IOCTL_SERVICE_STATUS,0,0,&dwStatus,sizeof(DWORD),0, 0);
    CloseHandle(hService);
    if(0 == fRet) {
        return 0xFFFFFFFF;
    } else {
        return dwStatus;
    }
     
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd )
{
  HRESULT hr = S_OK;
  // Query the OBEX state. Based on this state, the server is toggled 
  //   off or on, and the server status is printed.
  switch(OBEXQuery()) {
       // If the server is off, turn it back on.
       case SERVICE_STATE_OFF:
            OutputDebugString(L"Server is off -- starting\n");
            hr = OBEXIOCTL(IOCTL_SERVICE_START);
            break;
       // If the server is on, turn it off.
       case SERVICE_STATE_ON:
            OutputDebugString(L"Server is on -- stopping\n");
            hr = OBEXIOCTL(IOCTL_SERVICE_STOP); 
            break;
       // Print Obex server status.
       case SERVICE_STATE_STARTING_UP:
            OutputDebugString(L"Server is starting up\n");
            break;
       case SERVICE_STATE_SHUTTING_DOWN:
            OutputDebugString(L"Server is shutting down\n");
            break;
       case SERVICE_STATE_UNLOADING:
            OutputDebugString(L"Server is unloading\n");
            break;
       case SERVICE_STATE_UNINITIALIZED:
            OutputDebugString(L"Server is uninitialized\n");
            break;
       default:
            OutputDebugString(L"Server state is unknown at this time\n");
            break;
  };
   if(FAILED(hr)) {
     OutputDebugString(L"Setting device IOCTL failed\n");
  }
  return 0;
}

The following topics contain more information about OBEX server support:

Community Additions

ADD
Show:
© 2014 Microsoft