- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
In system init we have a init code like below:
APPLICATION_INIT()
{
bleapp_set_cfg((UINT8 *)hello_sensor_gatt_database,
sizeof(hello_sensor_gatt_database),
(void *)&hello_sensor_cfg,
(void *)&hello_sensor_puart_cfg,
(void *)&hello_sensor_gpio_cfg,
hello_sensor_create);
}
Is there any side effect if we want to read/write NV item in APPLICATION_INIT() ?
Pseudo code like below:
APPLICATION_INIT()
{
UINT8 databyte;
databyte = bleprofile_ReadNVRAM(NVRAM_ID_HOST_LIST, sizeof(hello_sensor_hostinfo), (UINT8 *)&hello_sensor_hostinfo);
if (databyte == 0) {
//Write initial 0 to the NVs and use another data base
...............
databyte = bleprofile_WriteNVRAM(NVRAM_ID_HOST_LIST, sizeof(hello_sensor_hostinfo), (UINT8 *)&hello_sensor_hostinfo);
bleapp_set_cfg((UINT8 *)hello_sensor_gatt_database2,
sizeof(hello_sensor_gatt_database2),
(void *)&hello_sensor_cfg2,
(void *)&hello_sensor_puart_cfg,
(void *)&hello_sensor_gpio_cfg,
hello_sensor_create);
}
else {
bleapp_set_cfg((UINT8 *)hello_sensor_gatt_database,
sizeof(hello_sensor_gatt_database),
(void *)&hello_sensor_cfg,
(void *)&hello_sensor_puart_cfg,
(void *)&hello_sensor_gpio_cfg,
hello_sensor_create);
}
}
Please kindly give a suggestion, thanks.
Solved! Go to Solution.
- Labels:
-
BLE_PROFILE_CFG
-
Debug
-
SDK 2.X
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following forum post has a piece of code attached which may be capable of what you want to do:
How to change the GATT database after init (bleapp_set_cfg) ?
I have never personally tried or it or know anyone who has, but it remains your best option to attempt a runtime GATT change.
The approach you were previously taken seems impossible unless you have two different physical boot sources and hardware to switch between the two.
Jacob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I haven't see this before. Can you access the nvram in the subsequent functions below?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This likely won't work since the i2c hardware shouldn't yet be initialized. No harm done in giving it a try though.
"Write initial 0 to the NVs and use another data base " Do you wish to change your boot source? That would require a hardware solution.
Jacob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
The main idea is want to use different GATT DB during the boot time, if we found there is a flag set in NV items. We will use the GATT DB2, if not, we will use DB1.
For example, originally we provide the standard battery service for client access, but if we set the flag, we will hide the battery service after next time booting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Boont,
Roughly test the dynamic change GATT method. Seems work, thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following forum post has a piece of code attached which may be capable of what you want to do:
How to change the GATT database after init (bleapp_set_cfg) ?
I have never personally tried or it or know anyone who has, but it remains your best option to attempt a runtime GATT change.
The approach you were previously taken seems impossible unless you have two different physical boot sources and hardware to switch between the two.
Jacob