0

I've been studying the echo bit sample from WDF Windows.

There is a function BthEchoSrvRegisterPSM in server.c which registers PSM.

It looks like that:

_IRQL_requires_max_(PASSIVE_LEVEL)
NTSTATUS
BthEchoSrvRegisterPSM(
    _In_ PBTHECHOSAMPLE_SERVER_CONTEXT DevCtx
    )
/*++

Description:

    Registers server PSM.

Arguments:

    DevCtx - Device context of the server

Return Value:

    NTSTATUS Status code.

--*/
{
    NTSTATUS status;
    struct _BRB_PSM * brb;

    DevCtx->Header.ProfileDrvInterface.BthReuseBrb(
        &(DevCtx->RegisterUnregisterBrb), 
        BRB_REGISTER_PSM
        );

    brb = (struct _BRB_PSM *)
            &(DevCtx->RegisterUnregisterBrb);
    
    //
    // Send in our preferred PSM
    //
    brb->Psm = DevCtx->Psm;

    status = BthEchoSharedSendBrbSynchronously(
        DevCtx->Header.IoTarget,
        DevCtx->Header.Request,
        (PBRB) brb,
        sizeof(*brb)
        );
    
    if (!NT_SUCCESS(status))
    {
        TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, 
            "BRB_REGISTER_PSM failed, Status code %!STATUS!\n", status);
        goto exit;        
    }

    //
    // Store PSM obtained
    //
    DevCtx->Psm = brb->Psm;

exit:
    return status;
}

My question is what is 'our preferred PSM'? Isn't PSM defined as a specific service? How can I set it for a remote device? Where does it come from?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user
  • 95
  • 1
  • 9
  • Refer to Bluetooth Core Specification to find our what PSM is. Next refer to Bluetooth assigned numbers to find our reserved PSM and its protocols. Next you can decided which one you should use. – Mike Petrichenko Mar 24 '21 at 12:30
  • I know my PSM, maybe my question wasn't so precised. What I meant, was I cann't see, how this is set in the sample. Where that it comes from? – user Mar 24 '21 at 12:35
  • The PSM passed to this function (DevCtx).. It then passed to the BthEchoSharedSendBrbSynchronously and once bth.sys processed the BRB it leaves it as requested or returns new one if requested is busy. – Mike Petrichenko Mar 24 '21 at 12:45
  • 1
    More infor can be found there: https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/bthddi/ns-bthddi-_brb_psm – Mike Petrichenko Mar 24 '21 at 12:47
  • Perfect. I couldn't find that before :) thank you for your patient. it's not the first time you are helping :) – user Mar 24 '21 at 12:49
  • You are very welcome. – Mike Petrichenko Mar 24 '21 at 12:55

0 Answers0