view src/cs/services/vibr/vibr_process.c @ 301:4bb5772a05a3

AT%SPVER: new command for setting custom speech version lists The speech version list in the Bearer Capability IE tells the network which speech codecs are supported by the MS, and in which order of preference. The standard behaviour is to list all codecs that are supported by the hw+fw platform, and the standard preference order is newer over older, FR over HR. But sometimes it is desirable (for network testing) to artificially restrict which codecs the test MS will declare as supported, and/or to list them in some peculiar non-standard order of preference. Add a new private AT command, AT%SPVER, allowing the user to set and clear custom speech version lists for the Bearer Capability IE composer in CC.
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 21 May 2023 21:43:10 +0000
parents e17bdedfbf2b
children
line wrap: on
line source

/*
 * In this module we are going to implement the main process functions
 * for VIBR.
 */

#include "vibr/vibr_env.h"
#include "vibr/vibr_func_i.h"
#include "rv/rv_general.h"
#include "rvf/rvf_api.h"
#include "rvm/rvm_use_id_list.h"
#include "main/sys_types.h"
#include "buzzer/vibrator.h"

/* duration of "on" and "off" phases of each vibration cycle */
#define	ON_PHASE_MS	500
#define	OFF_PHASE_MS	500

void vibr_process_start_req(struct vibr_start_msg *msg)
{
	vibr_env->vibr_level = msg->vibr_level;
	/* start the first pulse */
	HW_vibrator_on(vibr_env->vibr_level);
	vibr_env->on_state = TRUE;
	rvf_start_timer(VIBR_TIMER, RVF_MS_TO_TICKS(ON_PHASE_MS), FALSE);
	if (msg->num_pulses) {
		vibr_env->cont_mode = FALSE;
		vibr_env->remain_cycles = msg->num_pulses;
	} else
		vibr_env->cont_mode = TRUE;
}

void vibr_process_stop_req(struct vibr_stop_msg *msg)
{
	HW_vibrator_off();
	rvf_stop_timer(VIBR_TIMER);
}

static void on_phase_end(void)
{
	HW_vibrator_off();
	/* got more pulses? */
	if (!vibr_env->cont_mode) {
		vibr_env->remain_cycles--;
		if (!vibr_env->remain_cycles)
			return;		/* pulse train finished */
	}
	/* time the "off" phase before next pulse */
	vibr_env->on_state = FALSE;
	rvf_start_timer(VIBR_TIMER, RVF_MS_TO_TICKS(OFF_PHASE_MS), FALSE);
}

static void off_phase_end(void)
{
	/* start the next pulse */
	HW_vibrator_on(vibr_env->vibr_level);
	vibr_env->on_state = TRUE;
	rvf_start_timer(VIBR_TIMER, RVF_MS_TO_TICKS(ON_PHASE_MS), FALSE);
}

void vibr_handle_timer(void)
{
	if (vibr_env->on_state)
		on_phase_end();
	else
		off_phase_end();
}