Ejemplo n.º 1
0
/* enable alert on motion detect */
int mxuvc_alert_motion_enable(
	void (*callback)(alert_motion_data*, void *data),	/* callback with motion info */
	void *data)
{
	int ret = 0;
	alert_type type;

	CHECK_ERROR(check_alert_state() != 1, -1,
			"alert module is not initialized");
		
	if(alert_enable == 0)
		alert_enable = 1;
	else {
		CHECK_ERROR(alert_enable == 1, -1,
			"Motion alert module is already initialized");
	}
	type.b.audio_alert = 0;
	type.b.motion_alert = 1;

	ret = set_alert(type, ALARM_ACTION_ENABLE, 0, -1, 0, 0, 0, 0, 0, 0 );
	CHECK_ERROR(ret != 0, -1, "set_alert failed");

	motion_callback	= callback;
	cb_muser_data = data;
	
	return ret;
}
Ejemplo n.º 2
0
int mxuvc_alert_audio_set_threshold(unsigned int audioThresholdDB)
{
    int ret = 0;
    alert_type type;

    float PowVal;
    unsigned int aud_threshold_val;
    CHECK_ERROR(check_alert_state() != 1, -1,
            "alert module is not initialized");

    audio_threshold_dB = audioThresholdDB;
    if(alert_enable==0)
        return ret;

    type.d32 = 0;
    type.b.audio_alert = 1;
    //convert DB to Intensity
    PowVal = (float)(audio_threshold_dB/20.0);
    PowVal = pow(10, PowVal);
    aud_threshold_val = (unsigned int)(PowVal + 0.5);

    ret = set_alert(type, ALARM_ACTION_ENABLE, aud_threshold_val, NULL, 0, 0, 0);
    CHECK_ERROR(ret != 0, -1, "set_alert failed");

    return ret;
}