/*
 * Gets statistics from lowlevel backend and writes it to "backend" section
 */
static void fill_backend_backend(rapidjson::Value &stat_value,
                                 rapidjson::Document::AllocatorType &allocator,
                                 const struct dnet_backend_io *backend,
                                 const dnet_backend_info *config_backend) {
	char *json_stat = NULL;
	size_t size = 0;
	struct dnet_backend_callbacks *cb = backend->cb;
	if (cb->storage_stat_json) {
		cb->storage_stat_json(cb->command_private, &json_stat, &size);
		if (json_stat && size) {
			rapidjson::Document backend_value(&allocator);
			backend_value.Parse<0>(json_stat);
			auto &config_value = backend_value["config"];
			config_value.AddMember("group", config_backend->group, allocator);
			config_value.AddMember("queue_timeout", config_backend->queue_timeout, allocator);

			rapidjson::Document initial_config(&allocator);
			initial_config.Parse<0>(config_backend->initial_config.c_str());
			backend_value.AddMember("initial_config",
			                        static_cast<rapidjson::Value&>(initial_config),
			                        allocator);

			stat_value.AddMember("backend",
			                     static_cast<rapidjson::Value&>(backend_value),
			                     allocator);
		}
	}

	free(json_stat);
}
Example #2
0
//Initialise sensor for spo2 and hr measurements
static void init_sensor(){
    uint8_t int_mask; //Interrupt mask
    max30100_config_t config; //Configuration struct

    //Set initial configuration parameters
    config.spo2_config = (SPO2_HI_RES_EN		//Enable high resolution (LED pulse width = 1.6mS, 16 bit ADC resolution)
			 | SPO2_SR_100);		//Set sampling rate to 100 samples per second
    config.mode_config = HR_ONLY_EN;			//Enable heart rate only mode        
    config.led_config =  (RED_PA_50_0 			//Set red LED current to 50.0mA
			 | IR_PA_50_0);			//Set infra red LED current to 50.0mA

    //Configure sensor with initial config parameters at start up
    initial_config(config);
}