I need to be able to set some of the strings in the Device Information Service at runtime, using information received from a coprocessor. The stock implementation of DISS uses hard-coded strings in user_profiles_config.h. I am hoping this won't require a full re-implementation of the DISS service. Do you have recommendations (or reference code) for how to do this?
Device:
Hi mkelwood,
If you check the characteristics of the DISS profile, they have PERM(RI, ENABLE) as property. This property means that the values of the DISS profile are not stored into a database, like the custom profile. When the master is going to read a characteristic, the diss_value_req_ind_handler will be executed, the code will enter one of the “cases” of the handler, and the device will send one of these values. In order to set some of the strings in the DISS at runtime, using information received from a coprocessor, you could change the length and the data of the “case” you want into the app_diss_task.h with the values you want to add.
Thanks, PM_Dialog
Hi PM_Dialog,
Thank you for the answer. I was hoping to avoid direct modifications to the SDK, in case we ever upgrade it to a newer version. Instead, I attempted to modify the user_profiles_config.h file to use variables for the macros that will need to be set at runtime. For example, I made the following changes to user_profiles_config.h for the serial number characteristic:
/// Serial Number
//#define APP_DIS_SERIAL_NB_STR ("1.0.0.0-LE")
//#define APP_DIS_SERIAL_NB_STR_LEN (10)
extern char *DISSSerialNum;
#定义APP_DIS_SERIAL_NB_STR_LEN (32)
#定义APP_DIS_SERIAL_NB_STR DISSSerialNum
where the DISSSerialNum array would be defined elsewhere (in the main user_app.c file, for example). However, this build fails with a linker error:
C:\Users\mkelwood\AppData\Local\Temp\p2bc8-3(178): error: L6226E: Missing base address for region extern.
C:\Users\mkelwood\AppData\Local\Temp\p2bc8-3(178): error: L6292E: Ignoring unknown attribute 'char' specified for region extern.
C:\Users\mkelwood\AppData\Local\Temp\p2bc8-3(178): error: L6292E: Ignoring unknown attribute '*DISSSerialNum' specified for region extern.
C:\Users\mkelwood\AppData\Local\Temp\p2bc8-3(655): error: L6292E: Ignoring unknown attribute 'LR_IROM1' specified for region extern.
C:\Users\mkelwood\AppData\Local\Temp\p2bc8-3(655): error: L6228E: Expected '{', found '0...'.
C:\Users\mkelwood\AppData\Local\Temp\p2bc8-3: Error: L6372E: Image needs at least one load region.
For some reason the extern declaration is being interpreted as a memory region declaration. If I omit the extern decl from user_profiles_config.h, then app_diss_task.c fails to build with unknown symbol.
I'll continue working on this, but any suggestions would be very welcome.
Hello PM_Dialog,
Nevermind - I solved the problem. The user_profiles_config.h file is included in da1458x_config_basic.h file, which is in turn included in the scatterfile. I just needed to add the following to the extern declaration:
#ifndef ARM_SCATTERFILE
extern char DISSSerialNum[];
#endif /* ARM_SCATTERFILE */
Now it builds fine - I should be able to get what I want without modifying the SDK files directly. Thanks for your help.
Hi mkelwood,
Glad you find you solved your problem, and thanks for indicating.
Thanks, PM_Dialog