4 posts / 0 new
Last post
dhirajp15
Offline
Last seen:2 years 1 month ago
加入:2016-06-08 15:26
disabling the service

Hi Dialog,
I am trying to disable the device information service in ble_barebone example.
I replaced attmdb_svc_set_permission(diss_env.shdl, param->sec_lvl);
to attmdb_svc_set_permission(diss_env.shdl, PERM(SVC_HIDE, ENABLE)); in diss_enable_req_handler func in disk_task.c just to check if sevices get hidden.
I found that on connection the device information service (UUID) still appears along with the attribute names, but it do not allow to write or read the attribute .
SO now if I want to hide the entire device info service during execution, what changes should I make?

Device:
MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi dhirap15,

Hi dhirap15,

If you are connected previously with device (without hiding your service) probably the android would have cache the services and characteristics of your device so when connecting the services that the android would present would be the cached ones, but you are not going to be able to read or write them since the android doesn't actually sees them anymore. Restart your android application and you should be able to see that the diss service isn't there anymore.

Thanks MT_dialog

dhirajp15
Offline
Last seen:2 years 1 month ago
加入:2016-06-08 15:26
Hi MT_Dialog,

Hi MT_Dialog,
I am able to disbale the diss service during runtime by doing the following changes:
在user_callback_config.h:
static const struct prf_func_callbacks user_prf_funcs[] =
{
#if BLE_DIS_SERVER
{TASK_DISS,app_diss_create_db, user_app_diss_enable},
#endif
{TASK_NONE, NULL, NULL} // DO NOT MOVE. Must always be last
};

in user_barebone.c:
void user_app_diss_enable(void)
{
if(dev_info_flag==1)
{
attmdb_svc_set_permission(diss_env.shdl, PERM(SVC, ENABLE));
}
else
{
attmdb_svc_set_permission(diss_env.shdl, PERM(SVC, DISABLE));
}
}
so in the android app i need to clear cache as u have mentioned and it works ,thanks for the help!. I observed that on each connection the user_app_diss_enable() function is called. But the app_diss_create_db() is called only during initialization . Is there a way to create database at time of connection ? I want to show my Service UUID (data_base) only to selected devices.
Thanks Dhiraj

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi dhirajp15,

Hi dhirajp15,

Yes is possible to create the database upon connection, you can try to send the db_create command when connecting, but in order to make this work you will have to tweek parts of the SDK and its not recommended, i have checked if you can send the db_create when connecting, it worked, but the values in the db are populated through the confirmation message that the diss_create_db sends and the function that handles the confirmation message, before populating the data in the db checks the status of your application if its on DB_INIT state, and if it is continues with the db population.

To sum up if you place the creation of the db upon connection and remove the part that places the db creation upon initialization, you will end up with an empty diss database and you will have to change some parts of the SDK in order to make it function properly. Also i cant see the reason why, since you can hide your service from the central what is the reason of creating a service upon connection ?

Thanks MT_dialog