Hello everyone, I am just looking for your feedback for snipping of the C++ coding. Because bsec_get_state() and bsec_set_srare() with fread() and fwrite() example is absent from the BME68X Sensor API at the github site. Also, I am not very talented with C++, just a novice.
The program is compiled and running fine. But I am not sure if it is ACTUALLY working or not. I don’t have a debug tool to see if it is behaving appropriately. The coding is expecting to run on Raspberry Pi 4 it is using bsec_2-0-6-1_generic_release_04302021..
Here are the snipped coding with bsec gets_state() for loading state from file and is set to BSEC; Usual error check logics are removed to simplify.
bsec_state = fopen("/tmp/bme68x.state", "rb");
unit8_t = result;
result = fread(serialized_state, sizeof(unsigned char), BSEC_MAX_STATE_BLOB_SIZE, bsec_state);
bsec_result = bsec_set_state(serialized_state, n_serialized_state, work_buffer_state, n_work_buffer_state);
And here are tyhe snipped coding with bsec_set_state() and save state into the file.
bsec_state = fopen("/tmp/bme68x.state", "wb");
bsec_state = bsec_get_state(0, serialized_state, n_serialized_state, work_buffer_state, n_work_buffer_state, &n_serialized_state);
result = fwrite(serialized_state, sizeof(serialized_state), 1, bsec_state)