int humidity_v2_get_temperature_callback_configuration(HumidityV2 *humidity_v2, uint32_t *ret_period, bool *ret_value_has_to_change, char *ret_option, int16_t *ret_min, int16_t *ret_max) {
	DevicePrivate *device_p = humidity_v2->p;
	GetTemperatureCallbackConfiguration_Request request;
	GetTemperatureCallbackConfiguration_Response response;
	int ret;

	ret = packet_header_create(&request.header, sizeof(request), HUMIDITY_V2_FUNCTION_GET_TEMPERATURE_CALLBACK_CONFIGURATION, device_p->ipcon_p, device_p);

	if (ret < 0) {
		return ret;
	}

	ret = device_send_request(device_p, (Packet *)&request, (Packet *)&response);

	if (ret < 0) {
		return ret;
	}

	*ret_period = leconvert_uint32_from(response.period);
	*ret_value_has_to_change = response.value_has_to_change != 0;
	*ret_option = response.option;
	*ret_min = leconvert_int16_from(response.min);
	*ret_max = leconvert_int16_from(response.max);

	return ret;
}
int temperature_ir_get_object_temperature_callback_threshold(TemperatureIR *temperature_ir, char *ret_option, int16_t *ret_min, int16_t *ret_max) {
	DevicePrivate *device_p = temperature_ir->p;
	GetObjectTemperatureCallbackThreshold_ request;
	GetObjectTemperatureCallbackThresholdResponse_ response;
	int ret;

	ret = packet_header_create(&request.header, sizeof(request), TEMPERATURE_IR_FUNCTION_GET_OBJECT_TEMPERATURE_CALLBACK_THRESHOLD, device_p->ipcon_p, device_p);

	if (ret < 0) {
		return ret;
	}


	ret = device_send_request(device_p, (Packet *)&request, (Packet *)&response);

	if (ret < 0) {
		return ret;
	}
	*ret_option = response.option;
	*ret_min = leconvert_int16_from(response.min);
	*ret_max = leconvert_int16_from(response.max);



	return ret;
}
int current12_get_current_callback_threshold(Current12 *current12, char *ret_option, int16_t *ret_min, int16_t *ret_max) {
	DevicePrivate *device_p = current12->p;
	GetCurrentCallbackThreshold_ request;
	GetCurrentCallbackThresholdResponse_ response;
	int ret;

	ret = packet_header_create(&request.header, sizeof(request), CURRENT12_FUNCTION_GET_CURRENT_CALLBACK_THRESHOLD, device_p->ipcon_p, device_p);

	if (ret < 0) {
		return ret;
	}


	ret = device_send_request(device_p, (Packet *)&request, (Packet *)&response);

	if (ret < 0) {
		return ret;
	}
	*ret_option = response.option;
	*ret_min = leconvert_int16_from(response.min);
	*ret_max = leconvert_int16_from(response.max);



	return ret;
}
int rotary_poti_get_position_callback_threshold(RotaryPoti *rotary_poti, char *ret_option, int16_t *ret_min, int16_t *ret_max) {
	DevicePrivate *device_p = rotary_poti->p;
	GetPositionCallbackThreshold_ request;
	GetPositionCallbackThresholdResponse_ response;
	int ret;

	ret = packet_header_create(&request.header, sizeof(request), ROTARY_POTI_FUNCTION_GET_POSITION_CALLBACK_THRESHOLD, device_p->ipcon_p, device_p);

	if (ret < 0) {
		return ret;
	}


	ret = device_send_request(device_p, (Packet *)&request, (Packet *)&response);

	if (ret < 0) {
		return ret;
	}
	*ret_option = response.option;
	*ret_min = leconvert_int16_from(response.min);
	*ret_max = leconvert_int16_from(response.max);



	return ret;
}
Example #5
0
int distance_ir_get_distance_callback_threshold(DistanceIR *distance_ir, char *ret_option, int16_t *ret_min, int16_t *ret_max) {
	GetDistanceCallbackThreshold_ request;
	GetDistanceCallbackThresholdResponse_ response;
	int ret;

	ret = packet_header_create(&request.header, sizeof(request), DISTANCE_IR_FUNCTION_GET_DISTANCE_CALLBACK_THRESHOLD, distance_ir->ipcon, distance_ir);

	if (ret < 0) {
		return ret;
	}


	ret = device_send_request(distance_ir, (Packet *)&request, (Packet *)&response);

	if (ret < 0) {
		return ret;
	}
	*ret_option = response.option;
	*ret_min = leconvert_int16_from(response.min);
	*ret_max = leconvert_int16_from(response.max);



	return ret;
}
Example #6
0
int joystick_get_position(Joystick *joystick, int16_t *ret_x, int16_t *ret_y) {
	DevicePrivate *device_p = joystick->p;
	GetPosition_ request;
	GetPositionResponse_ response;
	int ret;

	ret = packet_header_create(&request.header, sizeof(request), JOYSTICK_FUNCTION_GET_POSITION, device_p->ipcon_p, device_p);

	if (ret < 0) {
		return ret;
	}


	ret = device_send_request(device_p, (Packet *)&request, (Packet *)&response);

	if (ret < 0) {
		return ret;
	}
	*ret_x = leconvert_int16_from(response.x);
	*ret_y = leconvert_int16_from(response.y);



	return ret;
}
Example #7
0
int imu_get_orientation(IMU *imu, int16_t *ret_roll, int16_t *ret_pitch, int16_t *ret_yaw) {
	GetOrientation_ request;
	GetOrientationResponse_ response;
	int ret;

	ret = packet_header_create(&request.header, sizeof(request), IMU_FUNCTION_GET_ORIENTATION, imu->ipcon, imu);

	if (ret < 0) {
		return ret;
	}


	ret = device_send_request(imu, (Packet *)&request, (Packet *)&response);

	if (ret < 0) {
		return ret;
	}
	*ret_roll = leconvert_int16_from(response.roll);
	*ret_pitch = leconvert_int16_from(response.pitch);
	*ret_yaw = leconvert_int16_from(response.yaw);



	return ret;
}
Example #8
0
int joystick_get_position_callback_threshold(Joystick *joystick, char *ret_option, int16_t *ret_min_x, int16_t *ret_max_x, int16_t *ret_min_y, int16_t *ret_max_y) {
	DevicePrivate *device_p = joystick->p;
	GetPositionCallbackThreshold_ request;
	GetPositionCallbackThresholdResponse_ response;
	int ret;

	ret = packet_header_create(&request.header, sizeof(request), JOYSTICK_FUNCTION_GET_POSITION_CALLBACK_THRESHOLD, device_p->ipcon_p, device_p);

	if (ret < 0) {
		return ret;
	}


	ret = device_send_request(device_p, (Packet *)&request, (Packet *)&response);

	if (ret < 0) {
		return ret;
	}
	*ret_option = response.option;
	*ret_min_x = leconvert_int16_from(response.min_x);
	*ret_max_x = leconvert_int16_from(response.max_x);
	*ret_min_y = leconvert_int16_from(response.min_y);
	*ret_max_y = leconvert_int16_from(response.max_y);



	return ret;
}
Example #9
0
int imu_get_angular_velocity(IMU *imu, int16_t *ret_x, int16_t *ret_y, int16_t *ret_z) {
	GetAngularVelocity_ request;
	GetAngularVelocityResponse_ response;
	int ret;

	ret = packet_header_create(&request.header, sizeof(request), IMU_FUNCTION_GET_ANGULAR_VELOCITY, imu->ipcon, imu);

	if (ret < 0) {
		return ret;
	}


	ret = device_send_request(imu, (Packet *)&request, (Packet *)&response);

	if (ret < 0) {
		return ret;
	}
	*ret_x = leconvert_int16_from(response.x);
	*ret_y = leconvert_int16_from(response.y);
	*ret_z = leconvert_int16_from(response.z);



	return ret;
}
Example #10
0
int imu_get_all_data(IMU *imu, int16_t *ret_acc_x, int16_t *ret_acc_y, int16_t *ret_acc_z, int16_t *ret_mag_x, int16_t *ret_mag_y, int16_t *ret_mag_z, int16_t *ret_ang_x, int16_t *ret_ang_y, int16_t *ret_ang_z, int16_t *ret_temperature) {
	GetAllData_ request;
	GetAllDataResponse_ response;
	int ret;

	ret = packet_header_create(&request.header, sizeof(request), IMU_FUNCTION_GET_ALL_DATA, imu->ipcon, imu);

	if (ret < 0) {
		return ret;
	}


	ret = device_send_request(imu, (Packet *)&request, (Packet *)&response);

	if (ret < 0) {
		return ret;
	}
	*ret_acc_x = leconvert_int16_from(response.acc_x);
	*ret_acc_y = leconvert_int16_from(response.acc_y);
	*ret_acc_z = leconvert_int16_from(response.acc_z);
	*ret_mag_x = leconvert_int16_from(response.mag_x);
	*ret_mag_y = leconvert_int16_from(response.mag_y);
	*ret_mag_z = leconvert_int16_from(response.mag_z);
	*ret_ang_x = leconvert_int16_from(response.ang_x);
	*ret_ang_y = leconvert_int16_from(response.ang_y);
	*ret_ang_z = leconvert_int16_from(response.ang_z);
	*ret_temperature = leconvert_int16_from(response.temperature);



	return ret;
}
Example #11
0
int imu_get_magnetic_field(IMU *imu, int16_t *ret_x, int16_t *ret_y, int16_t *ret_z) {
	GetMagneticField_ request;
	GetMagneticFieldResponse_ response;
	int ret;

	ret = packet_header_create(&request.header, sizeof(request), IMU_FUNCTION_GET_MAGNETIC_FIELD, imu->ipcon, imu);

	if (ret < 0) {
		return ret;
	}


	ret = device_send_request(imu, (Packet *)&request, (Packet *)&response);

	if (ret < 0) {
		return ret;
	}
	*ret_x = leconvert_int16_from(response.x);
	*ret_y = leconvert_int16_from(response.y);
	*ret_z = leconvert_int16_from(response.z);



	return ret;
}
Example #12
0
int imu_get_acceleration(IMU *imu, int16_t *ret_x, int16_t *ret_y, int16_t *ret_z) {
	GetAcceleration_ request;
	GetAccelerationResponse_ response;
	int ret;

	ret = packet_header_create(&request.header, sizeof(request), IMU_FUNCTION_GET_ACCELERATION, imu->ipcon, imu);

	if (ret < 0) {
		return ret;
	}


	ret = device_send_request(imu, (Packet *)&request, (Packet *)&response);

	if (ret < 0) {
		return ret;
	}
	*ret_x = leconvert_int16_from(response.x);
	*ret_y = leconvert_int16_from(response.y);
	*ret_z = leconvert_int16_from(response.z);



	return ret;
}
Example #13
0
int servo_get_degree(Servo *servo, uint8_t servo_num, int16_t *ret_min, int16_t *ret_max) {
	DevicePrivate *device_p = servo->p;
	GetDegree_ request;
	GetDegreeResponse_ response;
	int ret;

	ret = packet_header_create(&request.header, sizeof(request), SERVO_FUNCTION_GET_DEGREE, device_p->ipcon_p, device_p);

	if (ret < 0) {
		return ret;
	}

	request.servo_num = servo_num;

	ret = device_send_request(device_p, (Packet *)&request, (Packet *)&response);

	if (ret < 0) {
		return ret;
	}
	*ret_min = leconvert_int16_from(response.min);
	*ret_max = leconvert_int16_from(response.max);



	return ret;
}
Example #14
0
static void imu_callback_wrapper_magnetic_field(IMU *imu, Packet *packet) {
	MagneticFieldCallbackFunction callback_function = (MagneticFieldCallbackFunction)imu->registered_callbacks[IMU_CALLBACK_MAGNETIC_FIELD];
	void *user_data = imu->registered_callback_user_data[IMU_CALLBACK_MAGNETIC_FIELD];
	MagneticFieldCallback_ *callback = (MagneticFieldCallback_ *)packet;

	callback->x = leconvert_int16_from(callback->x);
	callback->y = leconvert_int16_from(callback->y);
	callback->z = leconvert_int16_from(callback->z);

	if (callback_function != NULL) {
		callback_function(callback->x, callback->y, callback->z, user_data);
	}
}
Example #15
0
static void imu_callback_wrapper_orientation(IMU *imu, Packet *packet) {
	OrientationCallbackFunction callback_function = (OrientationCallbackFunction)imu->registered_callbacks[IMU_CALLBACK_ORIENTATION];
	void *user_data = imu->registered_callback_user_data[IMU_CALLBACK_ORIENTATION];
	OrientationCallback_ *callback = (OrientationCallback_ *)packet;

	callback->roll = leconvert_int16_from(callback->roll);
	callback->pitch = leconvert_int16_from(callback->pitch);
	callback->yaw = leconvert_int16_from(callback->yaw);

	if (callback_function != NULL) {
		callback_function(callback->roll, callback->pitch, callback->yaw, user_data);
	}
}
Example #16
0
static void imu_callback_wrapper_acceleration(IMU *imu, Packet *packet) {
	AccelerationCallbackFunction callback_function = (AccelerationCallbackFunction)imu->registered_callbacks[IMU_CALLBACK_ACCELERATION];
	void *user_data = imu->registered_callback_user_data[IMU_CALLBACK_ACCELERATION];
	AccelerationCallback_ *callback = (AccelerationCallback_ *)packet;

	callback->x = leconvert_int16_from(callback->x);
	callback->y = leconvert_int16_from(callback->y);
	callback->z = leconvert_int16_from(callback->z);

	if (callback_function != NULL) {
		callback_function(callback->x, callback->y, callback->z, user_data);
	}
}
Example #17
0
static void imu_callback_wrapper_angular_velocity(IMU *imu, Packet *packet) {
	AngularVelocityCallbackFunction callback_function = (AngularVelocityCallbackFunction)imu->registered_callbacks[IMU_CALLBACK_ANGULAR_VELOCITY];
	void *user_data = imu->registered_callback_user_data[IMU_CALLBACK_ANGULAR_VELOCITY];
	AngularVelocityCallback_ *callback = (AngularVelocityCallback_ *)packet;

	callback->x = leconvert_int16_from(callback->x);
	callback->y = leconvert_int16_from(callback->y);
	callback->z = leconvert_int16_from(callback->z);

	if (callback_function != NULL) {
		callback_function(callback->x, callback->y, callback->z, user_data);
	}
}
Example #18
0
static void joystick_callback_wrapper_position_reached(DevicePrivate *device_p, Packet *packet) {
	PositionReachedCallbackFunction callback_function;
	void *user_data = device_p->registered_callback_user_data[JOYSTICK_CALLBACK_POSITION_REACHED];
	PositionReachedCallback_ *callback = (PositionReachedCallback_ *)packet;
	*(void **)(&callback_function) = device_p->registered_callbacks[JOYSTICK_CALLBACK_POSITION_REACHED];

	if (callback_function == NULL) {
		return;
	}

	callback->x = leconvert_int16_from(callback->x);
	callback->y = leconvert_int16_from(callback->y);

	callback_function(callback->x, callback->y, user_data);
}
Example #19
0
int imu_get_calibration(IMU *imu, uint8_t typ, int16_t ret_data[10]) {
	GetCalibration_ request;
	GetCalibrationResponse_ response;
	int ret;
	int i;

	ret = packet_header_create(&request.header, sizeof(request), IMU_FUNCTION_GET_CALIBRATION, imu->ipcon, imu);

	if (ret < 0) {
		return ret;
	}

	request.typ = typ;

	ret = device_send_request(imu, (Packet *)&request, (Packet *)&response);

	if (ret < 0) {
		return ret;
	}
	for (i = 0; i < 10; i++) ret_data[i] = leconvert_int16_from(response.data[i]);



	return ret;
}
Example #20
0
int servo_get_current_position(Servo *servo, uint8_t servo_num, int16_t *ret_position) {
	DevicePrivate *device_p = servo->p;
	GetCurrentPosition_ request;
	GetCurrentPositionResponse_ response;
	int ret;

	ret = packet_header_create(&request.header, sizeof(request), SERVO_FUNCTION_GET_CURRENT_POSITION, device_p->ipcon_p, device_p);

	if (ret < 0) {
		return ret;
	}

	request.servo_num = servo_num;

	ret = device_send_request(device_p, (Packet *)&request, (Packet *)&response);

	if (ret < 0) {
		return ret;
	}
	*ret_position = leconvert_int16_from(response.position);



	return ret;
}
Example #21
0
static void imu_callback_wrapper_all_data(IMU *imu, Packet *packet) {
	AllDataCallbackFunction callback_function = (AllDataCallbackFunction)imu->registered_callbacks[IMU_CALLBACK_ALL_DATA];
	void *user_data = imu->registered_callback_user_data[IMU_CALLBACK_ALL_DATA];
	AllDataCallback_ *callback = (AllDataCallback_ *)packet;

	callback->acc_x = leconvert_int16_from(callback->acc_x);
	callback->acc_y = leconvert_int16_from(callback->acc_y);
	callback->acc_z = leconvert_int16_from(callback->acc_z);
	callback->mag_x = leconvert_int16_from(callback->mag_x);
	callback->mag_y = leconvert_int16_from(callback->mag_y);
	callback->mag_z = leconvert_int16_from(callback->mag_z);
	callback->ang_x = leconvert_int16_from(callback->ang_x);
	callback->ang_y = leconvert_int16_from(callback->ang_y);
	callback->ang_z = leconvert_int16_from(callback->ang_z);
	callback->temperature = leconvert_int16_from(callback->temperature);

	if (callback_function != NULL) {
		callback_function(callback->acc_x, callback->acc_y, callback->acc_z, callback->mag_x, callback->mag_y, callback->mag_z, callback->ang_x, callback->ang_y, callback->ang_z, callback->temperature, user_data);
	}
}
static void temperature_ir_callback_wrapper_object_temperature_reached(DevicePrivate *device_p, Packet *packet) {
	ObjectTemperatureReachedCallbackFunction callback_function;
	void *user_data = device_p->registered_callback_user_data[TEMPERATURE_IR_CALLBACK_OBJECT_TEMPERATURE_REACHED];
	ObjectTemperatureReachedCallback_ *callback = (ObjectTemperatureReachedCallback_ *)packet;
	*(void **)(&callback_function) = device_p->registered_callbacks[TEMPERATURE_IR_CALLBACK_OBJECT_TEMPERATURE_REACHED];

	if (callback_function == NULL) {
		return;
	}

	callback->temperature = leconvert_int16_from(callback->temperature);

	callback_function(callback->temperature, user_data);
}
static void temperature_ir_callback_wrapper_ambient_temperature(DevicePrivate *device_p, Packet *packet) {
	AmbientTemperatureCallbackFunction callback_function;
	void *user_data = device_p->registered_callback_user_data[TEMPERATURE_IR_CALLBACK_AMBIENT_TEMPERATURE];
	AmbientTemperatureCallback_ *callback = (AmbientTemperatureCallback_ *)packet;
	*(void **)(&callback_function) = device_p->registered_callbacks[TEMPERATURE_IR_CALLBACK_AMBIENT_TEMPERATURE];

	if (callback_function == NULL) {
		return;
	}

	callback->temperature = leconvert_int16_from(callback->temperature);

	callback_function(callback->temperature, user_data);
}
static void current12_callback_wrapper_current_reached(DevicePrivate *device_p, Packet *packet) {
	CurrentReachedCallbackFunction callback_function;
	void *user_data = device_p->registered_callback_user_data[CURRENT12_CALLBACK_CURRENT_REACHED];
	CurrentReachedCallback_ *callback = (CurrentReachedCallback_ *)packet;
	*(void **)(&callback_function) = device_p->registered_callbacks[CURRENT12_CALLBACK_CURRENT_REACHED];

	if (callback_function == NULL) {
		return;
	}

	callback->current = leconvert_int16_from(callback->current);

	callback_function(callback->current, user_data);
}
static void rotary_poti_callback_wrapper_position_reached(DevicePrivate *device_p, Packet *packet) {
	PositionReachedCallbackFunction callback_function;
	void *user_data = device_p->registered_callback_user_data[ROTARY_POTI_CALLBACK_POSITION_REACHED];
	PositionReachedCallback_ *callback = (PositionReachedCallback_ *)packet;
	*(void **)(&callback_function) = device_p->registered_callbacks[ROTARY_POTI_CALLBACK_POSITION_REACHED];

	if (callback_function == NULL) {
		return;
	}

	callback->position = leconvert_int16_from(callback->position);

	callback_function(callback->position, user_data);
}
Example #26
0
static void servo_callback_wrapper_velocity_reached(DevicePrivate *device_p, Packet *packet) {
	VelocityReachedCallbackFunction callback_function;
	void *user_data = device_p->registered_callback_user_data[SERVO_CALLBACK_VELOCITY_REACHED];
	VelocityReachedCallback_ *callback = (VelocityReachedCallback_ *)packet;
	*(void **)(&callback_function) = device_p->registered_callbacks[SERVO_CALLBACK_VELOCITY_REACHED];

	if (callback_function == NULL) {
		return;
	}

	callback->velocity = leconvert_int16_from(callback->velocity);

	callback_function(callback->servo_num, callback->velocity, user_data);
}
static void humidity_v2_callback_wrapper_temperature(DevicePrivate *device_p, Packet *packet) {
	Temperature_CallbackFunction callback_function;
	void *user_data = device_p->registered_callback_user_data[DEVICE_NUM_FUNCTION_IDS + HUMIDITY_V2_CALLBACK_TEMPERATURE];
	Temperature_Callback *callback = (Temperature_Callback *)packet;

	*(void **)(&callback_function) = device_p->registered_callbacks[DEVICE_NUM_FUNCTION_IDS + HUMIDITY_V2_CALLBACK_TEMPERATURE];

	if (callback_function == NULL) {
		return;
	}

	callback->temperature = leconvert_int16_from(callback->temperature);

	callback_function(callback->temperature, user_data);
}
int humidity_v2_get_chip_temperature(HumidityV2 *humidity_v2, int16_t *ret_temperature) {
	DevicePrivate *device_p = humidity_v2->p;
	GetChipTemperature_Request request;
	GetChipTemperature_Response response;
	int ret;

	ret = packet_header_create(&request.header, sizeof(request), HUMIDITY_V2_FUNCTION_GET_CHIP_TEMPERATURE, device_p->ipcon_p, device_p);

	if (ret < 0) {
		return ret;
	}

	ret = device_send_request(device_p, (Packet *)&request, (Packet *)&response);

	if (ret < 0) {
		return ret;
	}

	*ret_temperature = leconvert_int16_from(response.temperature);

	return ret;
}
int motion_detector_v2_get_chip_temperature(MotionDetectorV2 *motion_detector_v2, int16_t *ret_temperature) {
	DevicePrivate *device_p = motion_detector_v2->p;
	GetChipTemperature_Request request;
	GetChipTemperature_Response response;
	int ret;

	ret = packet_header_create(&request.header, sizeof(request), MOTION_DETECTOR_V2_FUNCTION_GET_CHIP_TEMPERATURE, device_p->ipcon_p, device_p);

	if (ret < 0) {
		return ret;
	}

	ret = device_send_request(device_p, (Packet *)&request, (Packet *)&response);

	if (ret < 0) {
		return ret;
	}

	*ret_temperature = leconvert_int16_from(response.temperature);

	return ret;
}
int air_quality_get_chip_temperature(AirQuality *air_quality, int16_t *ret_temperature) {
	DevicePrivate *device_p = air_quality->p;
	GetChipTemperature_Request request;
	GetChipTemperature_Response response;
	int ret;

	ret = packet_header_create(&request.header, sizeof(request), AIR_QUALITY_FUNCTION_GET_CHIP_TEMPERATURE, device_p->ipcon_p, device_p);

	if (ret < 0) {
		return ret;
	}

	ret = device_send_request(device_p, (Packet *)&request, (Packet *)&response);

	if (ret < 0) {
		return ret;
	}

	*ret_temperature = leconvert_int16_from(response.temperature);

	return ret;
}