Closed chelliwell closed 4 years ago
"Hooking" the Bootstrap Information isn't directly possible, but persisting the Server and Security object contents may allow you to do what you need. See the relevant tutorial.
Thanks, I've been experimenting with the Persistence functions, and I can see how to tie this into one of the various avs_stream methods. I may need to implement my own, because I am writing to a region of Flash memory which needs a single 'commit'/'flush' at the end (i.e. it I can't do sequential writes such as on a file).
However I can't see whether the object persistence modules (e.g. server_persistence.c) ever call avs_stream_v_table_t.finish_method ...? (which I would need for doing my write of the accumulated object data to Flash). Or should I implement a 'close' in my custom stream handler?
Not sure if I can - with my own reader/writer/etc - use either stream_simple_io or stream_outbuf, or need to write my own. In which case which of those two is the better starting point?
We assume that flushing is performed in close
stream method, which - if implemented - is called when deleting the stream with avs_stream_cleanup
. If you are implementing your own avs_stream
, this is the way to go. finish_message
, while semantically being a flush operation, is not called automatically on cleanup.
Alternatively, if you are using stream_simple_io
, you may also perform the flush step explicitly after stream cleanup:
// setup whatever is necessary for writer() to function correctly:
// open a file, unlock flash etc
avs_stream_abstract_t *stream = avs_stream_simple_output_create(writer, context);
// call Anjay persistence methods
anjay_security_object_persist(anjay, stream);
// ...
avs_stream_cleanup(&stream);
// writer() will not be called any more, so if flush is required, do it here
I have a client app derived from the 'demo client', which I am using with bootstrapping. I'm trying to figure out if there is a way to 'hook' the response from the Bootstrap Server so that I can save the Server connection info to use on next reboot (i.e. instead of just re-bootstrap each time). Has anyone done this, and know where/how to grab the info?