mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-12 03:39:54 +00:00
cmake: fix warnings, code cleanup
This commit is contained in:
parent
b5232cd8d2
commit
3548b7cb21
@ -485,6 +485,7 @@ static void att_server_event_packet_handler (uint8_t packet_type, uint16_t chann
|
||||
static uint8_t
|
||||
att_server_send_prepared(const att_server_t *att_server, const att_connection_t *att_connection, uint8_t *buffer,
|
||||
uint16_t size) {
|
||||
UNUSED(buffer);
|
||||
uint8_t status = ERROR_CODE_SUCCESS;
|
||||
switch (att_server->bearer_type) {
|
||||
case ATT_BEARER_UNENHANCED_LE:
|
||||
@ -1638,4 +1639,4 @@ uint8_t att_server_eatt_init(uint8_t num_eatt_bearers, uint8_t * storage_buffer,
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@ -1557,7 +1557,7 @@ static int sm_le_device_db_index_lookup(bd_addr_type_t address_type, bd_addr_t a
|
||||
le_device_db_info(i, &db_address_type, db_address, NULL);
|
||||
// skip unused entries
|
||||
if (address_type == BD_ADDR_TYPE_UNKNOWN) continue;
|
||||
if ((address_type == db_address_type) && (memcmp(address, db_address, 6) == 0)){
|
||||
if ((address_type == (unsigned int)db_address_type) && (memcmp(address, db_address, 6) == 0)){
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
@ -61,8 +61,8 @@
|
||||
|
||||
static float rcos[CVSD_OLAL] = {
|
||||
0.99148655f,0.92510857f,
|
||||
0.80131732f,0.63683150f,
|
||||
0.45386582f,0.27713082f,
|
||||
0.80131732f,0.63683150f,
|
||||
0.45386582f,0.27713082f,
|
||||
0.13049554f,0.03376389f};
|
||||
|
||||
float btstack_cvsd_plc_rcos(int index){
|
||||
@ -78,7 +78,7 @@ static float sqrt3(const float x){
|
||||
float x;
|
||||
} u;
|
||||
u.x = x;
|
||||
u.i = (1<<29) + (u.i >> 1) - (1<<22);
|
||||
u.i = (1<<29) + (u.i >> 1) - (1<<22);
|
||||
|
||||
// Two Babylonian Steps (simplified from:)
|
||||
// u.x = 0.5f * (u.x + x/u.x);
|
||||
@ -95,10 +95,10 @@ static float btstack_cvsd_plc_absolute(float x){
|
||||
}
|
||||
|
||||
static float btstack_cvsd_plc_cross_correlation(BTSTACK_CVSD_PLC_SAMPLE_FORMAT *x, BTSTACK_CVSD_PLC_SAMPLE_FORMAT *y){
|
||||
float num = 0;
|
||||
float den = 0;
|
||||
float x2 = 0;
|
||||
float y2 = 0;
|
||||
float num = 0.f;
|
||||
float den = 0.f;
|
||||
float x2 = 0.f;
|
||||
float y2 = 0.f;
|
||||
int m;
|
||||
for (m=0;m<CVSD_M;m++){
|
||||
num+=((float)x[m])*y[m];
|
||||
@ -110,15 +110,15 @@ static float btstack_cvsd_plc_cross_correlation(BTSTACK_CVSD_PLC_SAMPLE_FORMAT *
|
||||
}
|
||||
|
||||
int btstack_cvsd_plc_pattern_match(BTSTACK_CVSD_PLC_SAMPLE_FORMAT *y){
|
||||
float maxCn = -999999.0; // large negative number
|
||||
float maxCn = -999999.f; // large negative number
|
||||
int bestmatch = 0;
|
||||
float Cn;
|
||||
int n;
|
||||
for (n=0;n<CVSD_N;n++){
|
||||
Cn = btstack_cvsd_plc_cross_correlation(&y[CVSD_LHIST-CVSD_M], &y[n]);
|
||||
Cn = btstack_cvsd_plc_cross_correlation(&y[CVSD_LHIST-CVSD_M], &y[n]);
|
||||
if (Cn>maxCn){
|
||||
bestmatch=n;
|
||||
maxCn = Cn;
|
||||
maxCn = Cn;
|
||||
}
|
||||
}
|
||||
return bestmatch;
|
||||
@ -127,10 +127,10 @@ int btstack_cvsd_plc_pattern_match(BTSTACK_CVSD_PLC_SAMPLE_FORMAT *y){
|
||||
float btstack_cvsd_plc_amplitude_match(btstack_cvsd_plc_state_t *plc_state, uint16_t num_samples, BTSTACK_CVSD_PLC_SAMPLE_FORMAT *y, BTSTACK_CVSD_PLC_SAMPLE_FORMAT bestmatch){
|
||||
UNUSED(plc_state);
|
||||
int i;
|
||||
float sumx = 0;
|
||||
float sumx = 0.f;
|
||||
float sumy = 0.000001f;
|
||||
float sf;
|
||||
|
||||
|
||||
for (i=0;i<num_samples;i++){
|
||||
sumx += btstack_cvsd_plc_absolute(y[CVSD_LHIST-num_samples+i]);
|
||||
sumy += btstack_cvsd_plc_absolute(y[bestmatch+i]);
|
||||
@ -138,14 +138,14 @@ float btstack_cvsd_plc_amplitude_match(btstack_cvsd_plc_state_t *plc_state, uint
|
||||
sf = sumx/sumy;
|
||||
// This is not in the paper, but limit the scaling factor to something reasonable to avoid creating artifacts
|
||||
if (sf<0.75f) sf=0.75f;
|
||||
if (sf>1.0) sf=1.0f;
|
||||
if (sf>1.f) sf=1.f;
|
||||
return sf;
|
||||
}
|
||||
|
||||
BTSTACK_CVSD_PLC_SAMPLE_FORMAT btstack_cvsd_plc_crop_sample(float val){
|
||||
float croped_val = val;
|
||||
if (croped_val > 32767.0) croped_val= 32767.0;
|
||||
if (croped_val < -32768.0) croped_val=-32768.0;
|
||||
if (croped_val > 32767.f) croped_val= 32767.f;
|
||||
if (croped_val < -32768.f) croped_val=-32768.f;
|
||||
return (BTSTACK_CVSD_PLC_SAMPLE_FORMAT) croped_val;
|
||||
}
|
||||
|
||||
@ -196,7 +196,7 @@ static FILE * open_octave_file(btstack_cvsd_plc_state_t *plc_state, octave_frame
|
||||
octave_base_name, plc_state->frame_count,
|
||||
octave_frame_type2str(octave_frame_type));
|
||||
oct_file_name[sizeof(oct_file_name) - 1] = 0;
|
||||
|
||||
|
||||
FILE * oct_file = fopen(oct_file_name, "wb");
|
||||
if (oct_file == NULL){
|
||||
printf("OCTAVE: could not open file %s\n", oct_file_name);
|
||||
@ -211,13 +211,13 @@ static void octave_fprintf_plot_history_frame(btstack_cvsd_plc_state_t *plc_stat
|
||||
char hist_name[10];
|
||||
snprintf(hist_name, sizeof(hist_name), "hist%d", plc_state->nbf);
|
||||
hist_name[sizeof(hist_name) - 1] = 0;
|
||||
|
||||
|
||||
octave_fprintf_array_int16(oct_file, hist_name, CVSD_LHIST, plc_state->hist);
|
||||
|
||||
fprintf(oct_file, "y = [min(%s):1000:max(%s)];\n", hist_name, hist_name);
|
||||
fprintf(oct_file, "x = zeros(1, size(y,2));\n");
|
||||
fprintf(oct_file, "b = [0: %d];\n", CVSD_LHIST+CVSD_FS+CVSD_RT+CVSD_OLAL);
|
||||
|
||||
|
||||
int pos = CVSD_FS;
|
||||
fprintf(oct_file, "shift_x = x + %d;\n", pos);
|
||||
|
||||
@ -233,48 +233,48 @@ static void octave_fprintf_plot_history_frame(btstack_cvsd_plc_state_t *plc_stat
|
||||
fprintf(oct_file, "lhist_rt_x = x + %d;\n", pos);
|
||||
|
||||
fprintf(oct_file, "pattern_window_x = x + %d;\n", CVSD_LHIST - CVSD_M);
|
||||
|
||||
|
||||
fprintf(oct_file, "hf = figure();\n");
|
||||
snprintf(title, sizeof(title), "PLC %s frame %d",
|
||||
octave_frame_type2str(octave_frame_type), frame_nr);
|
||||
title[sizeof(title) - 1] = 0;
|
||||
|
||||
|
||||
fprintf(oct_file, "hold on;\n");
|
||||
fprintf(oct_file, "h1 = plot(%s); \n", hist_name);
|
||||
|
||||
fprintf(oct_file, "title(\"%s\");\n", title);
|
||||
|
||||
fprintf(oct_file, "plot(lhist_x, y, 'k'); \n");
|
||||
fprintf(oct_file, "text(max(lhist_x) - 10, max(y)+1000, 'lhist'); \n");
|
||||
|
||||
fprintf(oct_file, "title(\"%s\");\n", title);
|
||||
|
||||
fprintf(oct_file, "plot(lhist_x, y, 'k'); \n");
|
||||
fprintf(oct_file, "text(max(lhist_x) - 10, max(y)+1000, 'lhist'); \n");
|
||||
|
||||
fprintf(oct_file, "plot(lhist_olal1_x, y, 'k'); \n");
|
||||
fprintf(oct_file, "text(max(lhist_olal1_x) - 10, max(y)+1000, 'OLAL'); \n");
|
||||
fprintf(oct_file, "text(max(lhist_olal1_x) - 10, max(y)+1000, 'OLAL'); \n");
|
||||
|
||||
fprintf(oct_file, "plot(lhist_fs_x, y, 'k'); \n");
|
||||
fprintf(oct_file, "text(max(lhist_fs_x) - 10, max(y)+1000, 'FS'); \n");
|
||||
fprintf(oct_file, "text(max(lhist_fs_x) - 10, max(y)+1000, 'FS'); \n");
|
||||
|
||||
fprintf(oct_file, "plot(lhist_olal2_x, y, 'k'); \n");
|
||||
fprintf(oct_file, "text(max(lhist_olal2_x) - 10, max(y)+1000, 'OLAL'); \n");
|
||||
fprintf(oct_file, "text(max(lhist_olal2_x) - 10, max(y)+1000, 'OLAL'); \n");
|
||||
|
||||
fprintf(oct_file, "plot(lhist_rt_x, y, 'k');\n");
|
||||
fprintf(oct_file, "text(max(lhist_rt_x) - 10, max(y)+1000, 'RT'); \n");
|
||||
fprintf(oct_file, "text(max(lhist_rt_x) - 10, max(y)+1000, 'RT'); \n");
|
||||
|
||||
if (octave_frame_type == OCTAVE_FRAME_TYPE_GOOD) return;
|
||||
|
||||
int x0 = plc_state->bestlag;
|
||||
int x1 = plc_state->bestlag + CVSD_M - 1;
|
||||
fprintf(oct_file, "plot(b(%d:%d), %s(%d:%d), 'rd'); \n", x0, x1, hist_name, x0, x1);
|
||||
fprintf(oct_file, "text(%d - 10, -10, 'bestlag'); \n", x0);
|
||||
fprintf(oct_file, "text(%d - 10, -10, 'bestlag'); \n", x0);
|
||||
|
||||
x0 = plc_state->bestlag + CVSD_M ;
|
||||
x1 = plc_state->bestlag + CVSD_M + CVSD_FS - 1;
|
||||
fprintf(oct_file, "plot(b(%d:%d), %s(%d:%d), 'kd'); \n", x0, x1, hist_name, x0, x1);
|
||||
|
||||
|
||||
x0 = CVSD_LHIST - CVSD_M;
|
||||
x1 = CVSD_LHIST - 1;
|
||||
fprintf(oct_file, "plot(b(%d:%d), %s(%d:%d), 'rd'); \n", x0, x1, hist_name, x0, x1);
|
||||
fprintf(oct_file, "plot(pattern_window_x, y, 'g'); \n");
|
||||
fprintf(oct_file, "text(max(pattern_window_x) - 10, max(y)+1000, 'M'); \n");
|
||||
fprintf(oct_file, "text(max(pattern_window_x) - 10, max(y)+1000, 'M'); \n");
|
||||
}
|
||||
|
||||
static void octave_fprintf_plot_output(btstack_cvsd_plc_state_t *plc_state, FILE * oct_file){
|
||||
@ -317,7 +317,7 @@ void btstack_cvsd_plc_bad_frame(btstack_cvsd_plc_state_t *plc_state, uint16_t nu
|
||||
int i;
|
||||
float sf = 1;
|
||||
plc_state->nbf++;
|
||||
|
||||
|
||||
if (plc_state->max_consecutive_bad_frames_nr < plc_state->nbf){
|
||||
plc_state->max_consecutive_bad_frames_nr = plc_state->nbf;
|
||||
}
|
||||
@ -330,26 +330,26 @@ void btstack_cvsd_plc_bad_frame(btstack_cvsd_plc_state_t *plc_state, uint16_t nu
|
||||
#ifdef OCTAVE_OUTPUT
|
||||
FILE * oct_file = open_octave_file(plc_state, OCTAVE_FRAME_TYPE_BAD);
|
||||
if (oct_file){
|
||||
octave_fprintf_plot_history_frame(plc_state, oct_file, plc_state->frame_count);
|
||||
octave_fprintf_plot_history_frame(plc_state, oct_file, plc_state->frame_count);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (plc_state->nbf==1){
|
||||
// the replication begins after the template match
|
||||
plc_state->bestlag += CVSD_M;
|
||||
|
||||
plc_state->bestlag += CVSD_M;
|
||||
|
||||
// Compute Scale Factor to Match Amplitude of Substitution Packet to that of Preceding Packet
|
||||
sf = btstack_cvsd_plc_amplitude_match(plc_state, num_samples, plc_state->hist, plc_state->bestlag);
|
||||
for (i=0; i<CVSD_OLAL; i++){
|
||||
val = sf*plc_state->hist[plc_state->bestlag+i];
|
||||
plc_state->hist[CVSD_LHIST+i] = btstack_cvsd_plc_crop_sample(val);
|
||||
}
|
||||
|
||||
|
||||
for (i=CVSD_OLAL; i<num_samples; i++){
|
||||
val = sf*plc_state->hist[plc_state->bestlag+i];
|
||||
val = sf*plc_state->hist[plc_state->bestlag+i];
|
||||
plc_state->hist[CVSD_LHIST+i] = btstack_cvsd_plc_crop_sample(val);
|
||||
}
|
||||
|
||||
|
||||
for (i=num_samples; i<(num_samples+CVSD_OLAL); i++){
|
||||
float left = sf*plc_state->hist[plc_state->bestlag+i];
|
||||
float right = plc_state->hist[plc_state->bestlag+i];
|
||||
@ -369,7 +369,7 @@ void btstack_cvsd_plc_bad_frame(btstack_cvsd_plc_state_t *plc_state, uint16_t nu
|
||||
for (i=0; i<num_samples; i++){
|
||||
out[i] = plc_state->hist[CVSD_LHIST+i];
|
||||
}
|
||||
|
||||
|
||||
// shift the history buffer
|
||||
for (i=0; i<(CVSD_LHIST+CVSD_RT+CVSD_OLAL); i++){
|
||||
plc_state->hist[i] = plc_state->hist[i+num_samples];
|
||||
@ -399,7 +399,7 @@ void btstack_cvsd_plc_good_frame(btstack_cvsd_plc_state_t *plc_state, uint16_t n
|
||||
for (i=0;i<CVSD_RT;i++){
|
||||
out[i] = plc_state->hist[CVSD_LHIST+i];
|
||||
}
|
||||
|
||||
|
||||
for (i=CVSD_RT;i<(CVSD_RT+CVSD_OLAL);i++){
|
||||
float left = plc_state->hist[CVSD_LHIST+i];
|
||||
float right = in[i];
|
||||
@ -498,7 +498,7 @@ void btstack_cvsd_plc_process_data(btstack_cvsd_plc_state_t * plc_state, bool is
|
||||
plc_state->good_frames_nr++;
|
||||
if (plc_state->good_frames_nr == 1){
|
||||
log_info("First good frame at index %d\n", plc_state->frame_count-1);
|
||||
}
|
||||
}
|
||||
plc_state->good_samples += num_samples;
|
||||
}
|
||||
}
|
||||
@ -507,5 +507,5 @@ void btstack_cvsd_dump_statistics(btstack_cvsd_plc_state_t * state){
|
||||
log_info("Good frames: %d\n", state->good_frames_nr);
|
||||
log_info("Bad frames: %d\n", state->bad_frames_nr);
|
||||
log_info("Zero frames: %d\n", state->zero_frames_nr);
|
||||
log_info("Max Consecutive bad frames: %d\n", state->max_consecutive_bad_frames_nr);
|
||||
log_info("Max Consecutive bad frames: %d\n", state->max_consecutive_bad_frames_nr);
|
||||
}
|
||||
|
@ -69,8 +69,8 @@ static uint8_t indices0[] = {
|
||||
/* Raised COSine table for OLA */
|
||||
static float rcos[SBC_OLAL] = {
|
||||
0.99148655f,0.96623611f,0.92510857f,0.86950446f,
|
||||
0.80131732f,0.72286918f,0.63683150f,0.54613418f,
|
||||
0.45386582f,0.36316850f,0.27713082f,0.19868268f,
|
||||
0.80131732f,0.72286918f,0.63683150f,0.54613418f,
|
||||
0.45386582f,0.36316850f,0.27713082f,0.19868268f,
|
||||
0.13049554f,0.07489143f,0.03376389f,0.00851345f
|
||||
};
|
||||
|
||||
@ -82,7 +82,7 @@ static float sqrt3(const float x){
|
||||
float x;
|
||||
} u;
|
||||
u.x = x;
|
||||
u.i = (1<<29) + (u.i >> 1) - (1<<22);
|
||||
u.i = (1<<29) + (u.i >> 1) - (1<<22);
|
||||
|
||||
// Two Babylonian Steps (simplified from:)
|
||||
// u.x = 0.5f * (u.x + x/u.x);
|
||||
@ -114,15 +114,15 @@ static float CrossCorrelation(SAMPLE_FORMAT *x, SAMPLE_FORMAT *y){
|
||||
}
|
||||
|
||||
static int PatternMatch(SAMPLE_FORMAT *y){
|
||||
float maxCn = -999999.0; // large negative number
|
||||
float maxCn = -999999.f; // large negative number
|
||||
int bestmatch = 0;
|
||||
float Cn;
|
||||
int n;
|
||||
for (n=0;n<SBC_N;n++){
|
||||
Cn = CrossCorrelation(&y[SBC_LHIST-SBC_M], &y[n]);
|
||||
Cn = CrossCorrelation(&y[SBC_LHIST-SBC_M], &y[n]);
|
||||
if (Cn>maxCn){
|
||||
bestmatch=n;
|
||||
maxCn = Cn;
|
||||
maxCn = Cn;
|
||||
}
|
||||
}
|
||||
return bestmatch;
|
||||
@ -133,7 +133,7 @@ static float AmplitudeMatch(SAMPLE_FORMAT *y, SAMPLE_FORMAT bestmatch) {
|
||||
float sumx = 0;
|
||||
float sumy = 0.000001f;
|
||||
float sf;
|
||||
|
||||
|
||||
for (i=0;i<SBC_FS;i++){
|
||||
sumx += absolute(y[SBC_LHIST-SBC_FS+i]);
|
||||
sumy += absolute(y[bestmatch+i]);
|
||||
@ -147,8 +147,8 @@ static float AmplitudeMatch(SAMPLE_FORMAT *y, SAMPLE_FORMAT bestmatch) {
|
||||
|
||||
static SAMPLE_FORMAT crop_sample(float val){
|
||||
float croped_val = val;
|
||||
if (croped_val > 32767.0) croped_val= 32767.0;
|
||||
if (croped_val < -32768.0) croped_val=-32768.0;
|
||||
if (croped_val > 32767.f) croped_val= 32767.f;
|
||||
if (croped_val < -32768.f) croped_val=-32768.f;
|
||||
return (SAMPLE_FORMAT) croped_val;
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ uint8_t * btstack_sbc_plc_zero_signal_frame(void){
|
||||
void btstack_sbc_plc_init(btstack_sbc_plc_state_t *plc_state){
|
||||
plc_state->nbf=0;
|
||||
plc_state->bestlag=0;
|
||||
memset(plc_state->hist,0,sizeof(plc_state->hist));
|
||||
memset(plc_state->hist,0,sizeof(plc_state->hist));
|
||||
}
|
||||
|
||||
#ifdef OCTAVE_OUTPUT
|
||||
@ -205,7 +205,7 @@ static FILE * open_octave_file(btstack_sbc_plc_state_t *plc_state, octave_frame_
|
||||
octave_base_name, plc_state->frame_count,
|
||||
octave_frame_type2str(octave_frame_type));
|
||||
oct_file_name[sizeof(oct_file_name) - 1] = 0;
|
||||
|
||||
|
||||
FILE * oct_file = fopen(oct_file_name, "wb");
|
||||
if (oct_file == NULL){
|
||||
printf("OCTAVE: could not open file %s\n", oct_file_name);
|
||||
@ -220,13 +220,13 @@ static void octave_fprintf_plot_history_frame(btstack_sbc_plc_state_t *plc_state
|
||||
char hist_name[10];
|
||||
snprintf(hist_name, sizeof(hist_name), "hist%d", plc_state->nbf);
|
||||
hist_name[sizeof(hist_name) - 1] = 0;
|
||||
|
||||
|
||||
octave_fprintf_array_int16(oct_file, hist_name, SBC_LHIST, plc_state->hist);
|
||||
|
||||
fprintf(oct_file, "y = [min(%s):1000:max(%s)];\n", hist_name, hist_name);
|
||||
fprintf(oct_file, "x = zeros(1, size(y,2));\n");
|
||||
fprintf(oct_file, "b = [0: %d];\n", SBC_LHIST+SBC_FS+SBC_RT+SBC_OLAL);
|
||||
|
||||
|
||||
int pos = SBC_FS;
|
||||
fprintf(oct_file, "shift_x = x + %d;\n", pos);
|
||||
|
||||
@ -242,48 +242,48 @@ static void octave_fprintf_plot_history_frame(btstack_sbc_plc_state_t *plc_state
|
||||
fprintf(oct_file, "lhist_rt_x = x + %d;\n", pos);
|
||||
|
||||
fprintf(oct_file, "pattern_window_x = x + %d;\n", SBC_LHIST - SBC_M);
|
||||
|
||||
|
||||
fprintf(oct_file, "hf = figure();\n");
|
||||
snprintf(title, sizeof(title), "PLC %s frame %d",
|
||||
octave_frame_type2str(octave_frame_type), frame_nr);
|
||||
title[sizeof(title) - 1] = 0;
|
||||
|
||||
|
||||
fprintf(oct_file, "hold on;\n");
|
||||
fprintf(oct_file, "h1 = plot(%s); \n", hist_name);
|
||||
|
||||
fprintf(oct_file, "title(\"%s\");\n", title);
|
||||
|
||||
fprintf(oct_file, "plot(lhist_x, y, 'k'); \n");
|
||||
fprintf(oct_file, "text(max(lhist_x) - 10, max(y)+1000, 'lhist'); \n");
|
||||
|
||||
fprintf(oct_file, "title(\"%s\");\n", title);
|
||||
|
||||
fprintf(oct_file, "plot(lhist_x, y, 'k'); \n");
|
||||
fprintf(oct_file, "text(max(lhist_x) - 10, max(y)+1000, 'lhist'); \n");
|
||||
|
||||
fprintf(oct_file, "plot(lhist_olal1_x, y, 'k'); \n");
|
||||
fprintf(oct_file, "text(max(lhist_olal1_x) - 10, max(y)+1000, 'OLAL'); \n");
|
||||
fprintf(oct_file, "text(max(lhist_olal1_x) - 10, max(y)+1000, 'OLAL'); \n");
|
||||
|
||||
fprintf(oct_file, "plot(lhist_fs_x, y, 'k'); \n");
|
||||
fprintf(oct_file, "text(max(lhist_fs_x) - 10, max(y)+1000, 'FS'); \n");
|
||||
fprintf(oct_file, "text(max(lhist_fs_x) - 10, max(y)+1000, 'FS'); \n");
|
||||
|
||||
fprintf(oct_file, "plot(lhist_olal2_x, y, 'k'); \n");
|
||||
fprintf(oct_file, "text(max(lhist_olal2_x) - 10, max(y)+1000, 'OLAL'); \n");
|
||||
fprintf(oct_file, "text(max(lhist_olal2_x) - 10, max(y)+1000, 'OLAL'); \n");
|
||||
|
||||
fprintf(oct_file, "plot(lhist_rt_x, y, 'k');\n");
|
||||
fprintf(oct_file, "text(max(lhist_rt_x) - 10, max(y)+1000, 'RT'); \n");
|
||||
fprintf(oct_file, "text(max(lhist_rt_x) - 10, max(y)+1000, 'RT'); \n");
|
||||
|
||||
if (octave_frame_type == OCTAVE_FRAME_TYPE_GOOD) return;
|
||||
|
||||
int x0 = plc_state->bestlag;
|
||||
int x1 = plc_state->bestlag + SBC_M - 1;
|
||||
fprintf(oct_file, "plot(b(%d:%d), %s(%d:%d), 'rd'); \n", x0, x1, hist_name, x0, x1);
|
||||
fprintf(oct_file, "text(%d - 10, -10, 'bestlag'); \n", x0);
|
||||
fprintf(oct_file, "text(%d - 10, -10, 'bestlag'); \n", x0);
|
||||
|
||||
x0 = plc_state->bestlag + SBC_M ;
|
||||
x1 = plc_state->bestlag + SBC_M + SBC_FS - 1;
|
||||
fprintf(oct_file, "plot(b(%d:%d), %s(%d:%d), 'kd'); \n", x0, x1, hist_name, x0, x1);
|
||||
|
||||
|
||||
x0 = SBC_LHIST - SBC_M;
|
||||
x1 = SBC_LHIST - 1;
|
||||
fprintf(oct_file, "plot(b(%d:%d), %s(%d:%d), 'rd'); \n", x0, x1, hist_name, x0, x1);
|
||||
fprintf(oct_file, "plot(pattern_window_x, y, 'g'); \n");
|
||||
fprintf(oct_file, "text(max(pattern_window_x) - 10, max(y)+1000, 'M'); \n");
|
||||
fprintf(oct_file, "text(max(pattern_window_x) - 10, max(y)+1000, 'M'); \n");
|
||||
}
|
||||
|
||||
static void octave_fprintf_plot_output(btstack_sbc_plc_state_t *plc_state, FILE * oct_file){
|
||||
@ -327,14 +327,14 @@ void btstack_sbc_plc_bad_frame(btstack_sbc_plc_state_t *plc_state, SAMPLE_FORMAT
|
||||
int i;
|
||||
float sf = 1;
|
||||
|
||||
plc_state->nbf++;
|
||||
plc_state->nbf++;
|
||||
plc_state->bad_frames_nr++;
|
||||
plc_state->frame_count++;
|
||||
|
||||
if (plc_state->max_consecutive_bad_frames_nr < plc_state->nbf){
|
||||
plc_state->max_consecutive_bad_frames_nr = plc_state->nbf;
|
||||
}
|
||||
|
||||
|
||||
if (plc_state->nbf==1){
|
||||
// printf("first bad frame\n");
|
||||
// Perform pattern matching to find where to replicate
|
||||
@ -344,14 +344,14 @@ void btstack_sbc_plc_bad_frame(btstack_sbc_plc_state_t *plc_state, SAMPLE_FORMAT
|
||||
#ifdef OCTAVE_OUTPUT
|
||||
FILE * oct_file = open_octave_file(plc_state, OCTAVE_FRAME_TYPE_BAD);
|
||||
if (oct_file){
|
||||
octave_fprintf_plot_history_frame(plc_state, oct_file, plc_state->frame_count);
|
||||
octave_fprintf_plot_history_frame(plc_state, oct_file, plc_state->frame_count);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (plc_state->nbf==1){
|
||||
// the replication begins after the template match
|
||||
plc_state->bestlag += SBC_M;
|
||||
|
||||
plc_state->bestlag += SBC_M;
|
||||
|
||||
// Compute Scale Factor to Match Amplitude of Substitution Packet to that of Preceding Packet
|
||||
sf = AmplitudeMatch(plc_state->hist, plc_state->bestlag);
|
||||
// printf("sf Apmlitude Match %f, new data %d, bestlag+M %d\n", sf, ZIRbuf[0], plc_state->hist[plc_state->bestlag]);
|
||||
@ -362,12 +362,12 @@ void btstack_sbc_plc_bad_frame(btstack_sbc_plc_state_t *plc_state, SAMPLE_FORMAT
|
||||
// val = sf*plc_state->hist[plc_state->bestlag+i];
|
||||
plc_state->hist[SBC_LHIST+i] = crop_sample(val);
|
||||
}
|
||||
|
||||
|
||||
for (i=SBC_OLAL; i<SBC_FS; i++){
|
||||
val = sf*plc_state->hist[plc_state->bestlag+i];
|
||||
val = sf*plc_state->hist[plc_state->bestlag+i];
|
||||
plc_state->hist[SBC_LHIST+i] = crop_sample(val);
|
||||
}
|
||||
|
||||
|
||||
for (i=SBC_FS; i<(SBC_FS+SBC_OLAL); i++){
|
||||
float left = sf*plc_state->hist[plc_state->bestlag+i];
|
||||
float right = plc_state->hist[plc_state->bestlag+i];
|
||||
@ -387,7 +387,7 @@ void btstack_sbc_plc_bad_frame(btstack_sbc_plc_state_t *plc_state, SAMPLE_FORMAT
|
||||
for (i=0; i<SBC_FS; i++){
|
||||
out[i] = plc_state->hist[SBC_LHIST+i];
|
||||
}
|
||||
|
||||
|
||||
// shift the history buffer
|
||||
for (i=0; i<(SBC_LHIST+SBC_RT+SBC_OLAL); i++){
|
||||
plc_state->hist[i] = plc_state->hist[i+SBC_FS];
|
||||
@ -421,10 +421,10 @@ void btstack_sbc_plc_good_frame(btstack_sbc_plc_state_t *plc_state, SAMPLE_FORMA
|
||||
for (i=0;i<SBC_RT;i++){
|
||||
out[i] = plc_state->hist[SBC_LHIST+i];
|
||||
}
|
||||
|
||||
|
||||
for (i = SBC_RT;i<(SBC_RT+SBC_OLAL);i++){
|
||||
float left = plc_state->hist[SBC_LHIST+i];
|
||||
float right = in[i];
|
||||
float right = in[i];
|
||||
val = (left*rcos[i-SBC_RT]) + (right*rcos[SBC_OLAL+SBC_RT-1-i]);
|
||||
out[i] = crop_sample(val);
|
||||
}
|
||||
@ -455,5 +455,5 @@ void btstack_sbc_plc_good_frame(btstack_sbc_plc_state_t *plc_state, SAMPLE_FORMA
|
||||
void btstack_sbc_dump_statistics(btstack_sbc_plc_state_t * state){
|
||||
log_info("Good frames: %d\n", state->good_frames_nr);
|
||||
log_info("Bad frames: %d\n", state->bad_frames_nr);
|
||||
log_info("Max Consecutive bad frames: %d\n", state->max_consecutive_bad_frames_nr);
|
||||
log_info("Max Consecutive bad frames: %d\n", state->max_consecutive_bad_frames_nr);
|
||||
}
|
||||
|
@ -2216,6 +2216,7 @@ void hfp_bcm_write_i2spcm_interface_param(hfp_connection_t * hfp_connection){
|
||||
#endif
|
||||
|
||||
void hfp_prepare_for_sco(hfp_connection_t * hfp_connection){
|
||||
UNUSED(hfp_connection);
|
||||
#ifdef ENABLE_CC256X_ASSISTED_HFP
|
||||
hfp_connection->cc256x_send_write_codec_config = true;
|
||||
if (hfp_connection->negotiated_codec == HFP_CODEC_MSBC){
|
||||
|
@ -672,8 +672,8 @@ bool sdp_record_matches_service_search_pattern(uint8_t *record, uint8_t *service
|
||||
// context { indent }
|
||||
#ifdef ENABLE_SDP_DES_DUMP
|
||||
static int de_traversal_dump_data(uint8_t * element, de_type_t de_type, de_size_t de_size, void *my_context){
|
||||
int indent = *(int*) my_context;
|
||||
int i;
|
||||
unsigned int indent = *(int*) my_context;
|
||||
unsigned int i;
|
||||
for (i=0; i<indent;i++) printf(" ");
|
||||
unsigned int pos = de_get_header_size(element);
|
||||
unsigned int end_pos = de_get_len(element);
|
||||
@ -698,7 +698,7 @@ static int de_traversal_dump_data(uint8_t * element, de_type_t de_type, de_size_
|
||||
}
|
||||
printf(", len %2u, value: '", len);
|
||||
for (i=0;i<len;i++){
|
||||
char c = element[pos + i];
|
||||
uint8_t c = element[pos + i];
|
||||
printf("%c", (c >= 0x20 && c <= 0x7f) ? c : '.');
|
||||
}
|
||||
printf("'\n");
|
||||
@ -727,7 +727,7 @@ static int de_traversal_dump_data(uint8_t * element, de_type_t de_type, de_size_
|
||||
|
||||
void de_dump_data_element(const uint8_t * record){
|
||||
#ifdef ENABLE_SDP_DES_DUMP
|
||||
int indent = 0;
|
||||
unsigned int indent = 0;
|
||||
// hack to get root DES, too.
|
||||
de_type_t type = de_get_element_type(record);
|
||||
de_size_t size = de_get_size_type(record);
|
||||
|
@ -1528,7 +1528,7 @@ static void mesh_configuration_client_network_transmit_handler(mesh_model_t *mes
|
||||
mesh_access_message_processed(pdu);
|
||||
}
|
||||
|
||||
const static mesh_operation_t mesh_configuration_client_model_operations[] = {
|
||||
static const mesh_operation_t mesh_configuration_client_model_operations[] = {
|
||||
{ MESH_FOUNDATION_OPERATION_BEACON_STATUS, 1, mesh_configuration_client_beacon_status_handler },
|
||||
{ MESH_FOUNDATION_OPERATION_COMPOSITION_DATA_STATUS, 10, mesh_configuration_client_composition_data_status_handler },
|
||||
{ MESH_FOUNDATION_OPERATION_DEFAULT_TTL_STATUS, 1, mesh_configuration_client_default_ttl_handler },
|
||||
|
@ -2219,7 +2219,7 @@ static void config_node_identity_set_handler(mesh_model_t *mesh_model, mesh_pdu_
|
||||
|
||||
//
|
||||
|
||||
const static mesh_operation_t mesh_configuration_server_model_operations[] = {
|
||||
static const mesh_operation_t mesh_configuration_server_model_operations[] = {
|
||||
{ MESH_FOUNDATION_OPERATION_APPKEY_ADD, 19, config_appkey_add_handler },
|
||||
{ MESH_FOUNDATION_OPERATION_APPKEY_DELETE, 3, config_appkey_delete_handler },
|
||||
{ MESH_FOUNDATION_OPERATION_APPKEY_GET, 2, config_appkey_get_handler },
|
||||
|
@ -139,7 +139,7 @@ static void generic_default_transition_time_status_handler(mesh_model_t *mesh_mo
|
||||
mesh_access_message_processed(pdu);
|
||||
}
|
||||
|
||||
const static mesh_operation_t mesh_generic_default_transition_time_model_operations[] = {
|
||||
static const mesh_operation_t mesh_generic_default_transition_time_model_operations[] = {
|
||||
{ MESH_GENERIC_DEFAULT_TRANSITION_TIME_STATUS, 0, generic_default_transition_time_status_handler },
|
||||
{ 0, 0, NULL }
|
||||
};
|
||||
|
@ -121,7 +121,7 @@ static void generic_default_transition_time_set_unacknowledged_handler(mesh_mode
|
||||
}
|
||||
|
||||
// Generic On Off Message
|
||||
const static mesh_operation_t mesh_generic_default_transition_time_model_operations[] = {
|
||||
static const mesh_operation_t mesh_generic_default_transition_time_model_operations[] = {
|
||||
{ MESH_GENERIC_DEFAULT_TRANSITION_TIME_GET, 0, generic_default_transition_time_get_handler },
|
||||
{ MESH_GENERIC_DEFAULT_TRANSITION_TIME_SET, 1, generic_default_transition_time_set_handler },
|
||||
{ MESH_GENERIC_DEFAULT_TRANSITION_TIME_SET_UNACKNOWLEDGED, 1, generic_default_transition_time_set_unacknowledged_handler },
|
||||
|
@ -250,7 +250,7 @@ static void generic_level_status_handler(mesh_model_t *mesh_model, mesh_pdu_t *
|
||||
mesh_access_message_processed(pdu);
|
||||
}
|
||||
|
||||
const static mesh_operation_t mesh_generic_level_model_operations[] = {
|
||||
static const mesh_operation_t mesh_generic_level_model_operations[] = {
|
||||
{ MESH_GENERIC_LEVEL_STATUS, 0, generic_level_status_handler },
|
||||
{ 0, 0, NULL }
|
||||
};
|
||||
|
@ -344,7 +344,7 @@ static void generic_move_set_unacknowledged_handler(mesh_model_t *generic_level_
|
||||
}
|
||||
|
||||
// Generic On Off Message
|
||||
const static mesh_operation_t mesh_generic_level_model_operations[] = {
|
||||
static const mesh_operation_t mesh_generic_level_model_operations[] = {
|
||||
{ MESH_GENERIC_LEVEL_GET, 0, generic_level_get_handler },
|
||||
{ MESH_GENERIC_LEVEL_SET, 3, generic_level_set_handler },
|
||||
{ MESH_GENERIC_LEVEL_SET_UNACKNOWLEDGED, 3, generic_level_set_unacknowledged_handler },
|
||||
|
@ -171,7 +171,7 @@ static void generic_on_off_status_handler(mesh_model_t *mesh_model, mesh_pdu_t *
|
||||
mesh_access_message_processed(pdu);
|
||||
}
|
||||
|
||||
const static mesh_operation_t mesh_generic_on_off_model_operations[] = {
|
||||
static const mesh_operation_t mesh_generic_on_off_model_operations[] = {
|
||||
{ MESH_GENERIC_ON_OFF_STATUS, 0, generic_on_off_status_handler },
|
||||
{ 0, 0, NULL }
|
||||
};
|
||||
|
@ -198,7 +198,7 @@ static void generic_on_off_set_unacknowledged_handler(mesh_model_t *generic_on_o
|
||||
}
|
||||
|
||||
// Generic On Off Message
|
||||
const static mesh_operation_t mesh_generic_on_off_model_operations[] = {
|
||||
static const mesh_operation_t mesh_generic_on_off_model_operations[] = {
|
||||
{ MESH_GENERIC_ON_OFF_GET, 0, generic_on_off_get_handler },
|
||||
{ MESH_GENERIC_ON_OFF_SET, 2, generic_on_off_set_handler },
|
||||
{ MESH_GENERIC_ON_OFF_SET_UNACKNOWLEDGED, 2, generic_on_off_set_unacknowledged_handler },
|
||||
|
@ -327,7 +327,7 @@ static mesh_pdu_t * mesh_health_server_publish_state_fn(struct mesh_model * mesh
|
||||
}
|
||||
|
||||
// Health Message
|
||||
const static mesh_operation_t mesh_health_model_operations[] = {
|
||||
static const mesh_operation_t mesh_health_model_operations[] = {
|
||||
{ MESH_FOUNDATION_OPERATION_HEALTH_FAULT_GET, 2, health_fault_get_handler },
|
||||
{ MESH_FOUNDATION_OPERATION_HEALTH_FAULT_CLEAR, 2, health_fault_clear_handler },
|
||||
{ MESH_FOUNDATION_OPERATION_HEALTH_FAULT_CLEAR_UNACKNOWLEDGED, 2, health_fault_clear_unacknowledged_handler },
|
||||
|
Loading…
x
Reference in New Issue
Block a user