8 years, 7 months ago.

Using ReadAuthorization Callbacks

I'm working on a BLE device that needs max security, but for various reasons can't use OOB, or passkey, so we're putting an additional authorisation layer within the application, and want to set the read authorisation of my device characteristics explicitly. I've tried the following to test the usage, but doesn't seem to work.

// inside constructor
myCharacterisitic.requireSecurity(SecurityManager::SECURITY_MODE_ENCRYPTION_WITH_MITM); 
myCharacterisitic.setReadAuthorizationCallback(this, &LockFunctionService::onReadRequest);

...

protected:
// testing read authorisation
    virtual void onReadRequest(GattReadAuthCallbackParams *params) {        
        params->authorizationReply = AUTH_CALLBACK_REPLY_ATTERR_READ_NOT_PERMITTED;
    }

Once the link is paired/encrypted (I'm using Nordic sniffer dongle and Master Control Panel for testing) I can read/write to the chars without restriction, including the "myCharacteristic" which should be always unauthorised.

Am I using the API correctly?

Regards Andrew

Hi Andrew - did you ever figure this out? Been working on implementing something very similar but not having much success!

posted by Ian Martin 04 Aug 2016
Be the first to answer this question.