/* Find the next security instance for bootstrapping. 
Search for the next security instance that has the bootstrap flag set and is not the same as current security instance. */
static int sm_next_bootstrap_inst(int *sec_obj_inst)
/* Find the next security instance for bootstrapping. 
Search for the next security instance that has the bootstrap flag set and is not the same as current security instance. */
static int sm_next_bootstrap_inst(int *sec_obj_inst)
{
	int i, obj_inst_id = -1;
	if (*sec_obj_inst >= 0 && !is_bootsrap_server(*sec_obj_inst)) {
		*sec_obj_inst = -1;
	}
	for (i = 0; i < CONFIG_LWM2M_SECURITY_INSTANCE_COUNT; i++) {
		obj_inst_id = lwm2m_security_index_to_inst_id(i);
		if (obj_inst_id < 0) {
			continue;
		}
		if (obj_inst_id == *sec_obj_inst) {
			continue;
		}
		if (is_bootsrap_server(obj_inst_id)) {
			*sec_obj_inst = obj_inst_id;
			return 0;
		}
	}
	LOG_WRN("No Bootstrap servers found.");
	return -ENOENT;
}