Characteristic write permissions

Hi!
I have a problem setting write permissions.

For read characteristic all works as expected, with
PERM(RD, ENABLE) | PERM(RP, AUTH)
only paired devices can read.

But for write characteristic with
PERM(WRITE_REQ, ENABLE) | PERM(WRITE_REQ, AUTH)
any (also unpaired) device can write.

Please help - how to restrict access to write characteristic?

Best reggads,
Karlis

Is it possible you have also enabled WRITE_CMD without requiring authorization and the unpaired device is issuing WRITE_CMD?

1 Like

No, WRITE_CMD is not enabled,
maybe there is something I missed or overdefined:

    CS_CHAR_UUID_128(CS_COMMAND_CHAR0,
            CS_COMMAND_VAL0,
            CS_COMMAND_UUID,
            PERM(WRITE_REQ, ENABLE) | PERM(WRITE_REQ, AUTH),
            sizeof(app_env_cs.command_buffer),
            app_env_cs.command_buffer,
            CUSTOMSS_CharsCallback),

Hi @Karlis,

Can you please try using the following to set write permissions when defining your custom attribute database:

(PERM(WRITE_REQ, ENABLE) | PERM(WP, AUTH))

The first macro will tell the database to enable write requests for the specific attribute, and the second will tell it to require authentication when trying to write to it.

Hi,
thanks for pointing out where is my mistake, now it works!

Have a nice day!

1 Like