- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Uh oh, working with some other SDK's that support writing/reading data to flash, I thought this would be well supported in WICED.
How do I write a string (or any BLOB) to a persistent location and also read that string (or BLOB) back? And then write a changed string (or BLOB) back to the location?
I understand underlying FLASH issues with re-writing - but I really don't want to have to deal with that.
Surely there is some support in WICED or at least some contributed code that deals with this need.
I don't need a lot of space.maybe just 1KB or so.
Solved! Go to Solution.
- Labels:
-
SDK 3.x
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
you can use the DCT for that purpose. A section is reserved at the end of it, so you can link your personnal data there.
You can do something like this:
typedef struct {
int my_int;
} dct_data_t;
const dct_data_t _app_dct = {
.my_int = 42,
};
This will add a section in the DCT containing an integer, and initialized to 42.
To access it, you can do as follow:
dct_data_t *data;
wiced_dct_read_lock ((void **) &data, WICED_TRUE, DCT_APP_SECTION, 0, sizeof (dct_data_t));
data->my_int = 0;
wiced_dct_write (data, DCT_APP_SECTION, 0, sizeof (dct_data_t));
wiced_dct_read_unlock (data, WICED_TRUE);
Like this you have modified your own data and set my_int to 0.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Note, Using WICED C API's
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
you can use the DCT for that purpose. A section is reserved at the end of it, so you can link your personnal data there.
You can do something like this:
typedef struct {
int my_int;
} dct_data_t;
const dct_data_t _app_dct = {
.my_int = 42,
};
This will add a section in the DCT containing an integer, and initialized to 42.
To access it, you can do as follow:
dct_data_t *data;
wiced_dct_read_lock ((void **) &data, WICED_TRUE, DCT_APP_SECTION, 0, sizeof (dct_data_t));
data->my_int = 0;
wiced_dct_write (data, DCT_APP_SECTION, 0, sizeof (dct_data_t));
wiced_dct_read_unlock (data, WICED_TRUE);
Like this you have modified your own data and set my_int to 0.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Oliver!
So it is quite easy after all!
I did have an issue with the initialization to 42 not occurring when the new DCT was downloaded, but I found that I needed to follow the pattern in snip/config_mode including the config_mode_dct.[ch] files as well as the config_mode.mk. When I did that, initialization and everything worked quite nicely.
Thanks again!
PS: If there's any additional documentation besides what's in the doc directory, I'd love to have a link / the document.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
One more thing... in addition to DCT docs, is there anything related to writing thousands of times that I need to be concerned about? Is it managing and reclaiming FLASH nicely?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well that would depend on the flash you are using, but I think nowadays flash should support enough erase/write cycles for you don't need to be concerned about it. Data are being swapped from a sector to another (on STMF205 at least, DCT uses two sectors, but only one active at a time).