-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathext.c
1157 lines (1056 loc) · 27.3 KB
/
ext.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Copyright (C)
* 2017 - John Melton, G0ORX/N6LYT
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <gtk/gtk.h>
#include "main.h"
#include "discovery.h"
#include "receiver.h"
#include "sliders.h"
#include "toolbar.h"
#include "band_menu.h"
#include "diversity_menu.h"
#include "vfo.h"
#include "radio.h"
#include "radio_menu.h"
#include "new_menu.h"
#include "new_protocol.h"
#ifdef PURESIGNAL
#include "ps_menu.h"
#endif
#include "agc.h"
#include "filter.h"
#include "mode.h"
#include "band.h"
#include "bandstack.h"
#include "noise_menu.h"
#include "wdsp.h"
#ifdef CLIENT_SERVER
#include "client_server.h"
#endif
#include "ext.h"
#include "zoompan.h"
// The following calls functions can be called usig g_idle_add
int ext_menu_filter(void *data) {
start_filter();
return 0;
}
int ext_menu_mode(void *data) {
start_mode();
return 0;
}
int ext_num_pad(void *data) {
gint val=GPOINTER_TO_INT(data);
RECEIVER *rx=active_receiver;
if(!vfo[rx->id].entering_frequency) {
vfo[rx->id].entered_frequency=0;
vfo[rx->id].entering_frequency=TRUE;
}
switch(val) {
case -1: // clear
vfo[rx->id].entered_frequency=0;
vfo[rx->id].entering_frequency=FALSE;
break;
case -2: // enter
if(vfo[rx->id].entered_frequency!=0) {
vfo[rx->id].frequency=vfo[rx->id].entered_frequency;
if(vfo[rx->id].ctun) {
vfo[rx->id].ctun=FALSE;
vfo[rx->id].offset=0;
vfo[rx->id].ctun_frequency=vfo[rx->id].frequency;
}
}
vfo[rx->id].entering_frequency=FALSE;
break;
default:
vfo[rx->id].entered_frequency=(vfo[rx->id].entered_frequency*10)+val;
break;
}
vfo_update(rx);
return 0;
}
int ext_vfo_mode_changed(void * data)
{
int mode=GPOINTER_TO_INT(data);
vfo_mode_changed(mode);
return 0;
}
int ext_discovery(void *data) {
discovery();
return 0;
}
void local_set_frequency(int v,long long f) {
int b=get_band_from_frequency(f);
if(active_receiver->id==v) {
if (b != vfo[v].band) {
vfo_band_changed(active_receiver->id,b);
}
setFrequency(f);
} else if(v==VFO_B) {
// just changing VFO-B frequency
vfo[v].frequency=f;
vfo[v].band=b;
if(receivers==2) {
// need to change the receiver frequency
}
}
}
int ext_set_frequency(void *data) {
//
// If new frequency is outside of current band,
// behave as if the user had chosen the new band
// via the menu prior to changing the frequency
//
SET_FREQUENCY *set_frequency=(SET_FREQUENCY *)data;
local_set_frequency(set_frequency->vfo,set_frequency->frequency);
free(data);
return 0;
}
static guint vfo_timeout=0;
static int vfo_timeout_cb(void * data) {
vfo_timeout=0;
vfo_update();
return 0;
}
//
// ALL calls to vfo_update should go through g_idle_add(ext_vfo_update)
// such that they can be filtered out if they come at high rate
//
int ext_vfo_update(void *data) {
if (vfo_timeout==0) {
vfo_timeout=g_timeout_add(100, vfo_timeout_cb, NULL);
}
return 0;
}
int ext_vfo_filter_changed(void *data) {
vfo_filter_changed(GPOINTER_TO_INT(data));
return 0;
}
int ext_band_update(void *data) {
if(data==NULL) {
start_band();
} else {
band_select_cb(NULL,data);
}
return 0;
}
int ext_bandstack_update(void *data) {
start_bandstack();
return 0;
}
int ext_mode_update(void *data) {
start_mode();
return 0;
}
int ext_filter_update(void *data) {
start_filter();
return 0;
}
int ext_frequency_update(void *data) {
start_vfo(active_receiver->id);
return 0;
}
int ext_memory_update(void *data) {
start_store();
return 0;
}
int ext_noise_update(void *data) {
start_noise();
return 0;
}
int ext_mox_update(void *data) {
mox_update(GPOINTER_TO_INT(data));
return 0;
}
int ext_tune_update(void *data) {
tune_update(GPOINTER_TO_INT(data));
return 0;
}
int ext_vox_changed(void *data) {
vox_changed(GPOINTER_TO_INT(data));
return 0;
}
int ext_update_agc_gain(void *data) {
update_agc_gain(GPOINTER_TO_INT(data));
free(data);
return 0;
}
int ext_update_af_gain(void *data) {
update_af_gain();
return 0;
}
int ext_calc_drive_level(void *data) {
calcDriveLevel();
return 0;
}
int ext_vfo_band_changed(void *data) {
int b=GPOINTER_TO_INT(data);
vfo_band_changed(active_receiver->id,b);
return 0;
}
int ext_radio_change_sample_rate(void *data) {
radio_change_sample_rate(GPOINTER_TO_INT(data));
return 0;
}
int ext_update_squelch(void *data) {
set_squelch();
return 0;
}
int ext_sliders_update(void *data) {
sliders_update();
return 0;
}
#ifdef PURESIGNAL
int ext_tx_set_ps(void *data) {
if(can_transmit) {
int state=GPOINTER_TO_INT(data);
tx_set_ps(transmitter, state);
}
return 0;
}
#endif
int ext_update_vfo_step(void *data) {
int direction=GPOINTER_TO_INT(data);
int i = vfo_get_stepindex();
direction > 0 ? i++ : i--;
vfo_set_step_from_index(i);
g_idle_add(ext_vfo_update, NULL);
return 0;
}
int ext_vfo_step(void *data) {
int step=GPOINTER_TO_INT(data);
vfo_step(step);
return 0;
}
int ext_vfo_id_step(void *data) {
int *ip=(int *) data;
int id=ip[0];
int step=ip[1];
vfo_id_step(id,step);
free(data);
return 0;
}
int ext_set_mic_gain(void * data) {
double d=*(double *)data;
set_mic_gain(d);
free(data);
return 0;
}
int ext_set_af_gain(void *data) {
double d=*(double *)data;
set_af_gain(active_receiver->id,d);
free(data);
return 0;
}
int ext_set_agc_gain(void *data) {
double d=*(double *)data;
set_agc_gain(active_receiver->id,d);
free(data);
return 0;
}
int ext_set_drive(void *data) {
double d=*(double *)data;
set_drive(d);
free(data);
return 0;
}
int ext_set_compression(void *data) {
if(can_transmit) {
set_compression(transmitter);
}
return 0;
}
int ext_vfo_a_swap_b(void *data) {
vfo_a_swap_b();
return 0;
}
int ext_vfo_a_to_b(void *data) {
vfo_a_to_b();
return 0;
}
int ext_vfo_b_to_a(void *data) {
vfo_b_to_a();
return 0;
}
int ext_update_att_preamp(void *data) {
update_att_preamp();
return 0;
}
int ext_set_alex_attenuation(void *data) {
int val=GPOINTER_TO_INT(data);
set_alex_attenuation(val);
return 0;
}
int ext_set_attenuation_value(void *data) {
double d=*(double *)data;
set_attenuation_value(d);
free(data);
return 0;
}
#ifdef PURESIGNAL
int ext_ps_update(void *data) {
if(can_transmit) {
if(transmitter->puresignal==0) {
tx_set_ps(transmitter,1);
} else {
tx_set_ps(transmitter,0);
}
}
return 0;
}
#endif
int ext_two_tone(void *data) {
if(can_transmit) {
int state=transmitter->twotone?0:1;
tx_set_twotone(transmitter,state);
}
return 0;
}
int ext_nr_update(void *data) {
if(active_receiver->nr==0 && active_receiver->nr2==0) {
active_receiver->nr=1;
active_receiver->nr2=0;
mode_settings[vfo[active_receiver->id].mode].nr=1;
mode_settings[vfo[active_receiver->id].mode].nr2=0;
} else if(active_receiver->nr==1 && active_receiver->nr2==0) {
active_receiver->nr=0;
active_receiver->nr2=1;
mode_settings[vfo[active_receiver->id].mode].nr=0;
mode_settings[vfo[active_receiver->id].mode].nr2=1;
} else if(active_receiver->nr==0 && active_receiver->nr2==1) {
active_receiver->nr=0;
active_receiver->nr2=0;
mode_settings[vfo[active_receiver->id].mode].nr=0;
mode_settings[vfo[active_receiver->id].mode].nr2=0;
}
update_noise();
return 0;
}
int ext_nb_update(void *data) {
if(active_receiver->nb==0 && active_receiver->nb2==0) {
active_receiver->nb=1;
active_receiver->nb2=0;
mode_settings[vfo[active_receiver->id].mode].nb=1;
mode_settings[vfo[active_receiver->id].mode].nb2=0;
} else if(active_receiver->nb==1 && active_receiver->nb2==0) {
active_receiver->nb=0;
active_receiver->nb2=1;
mode_settings[vfo[active_receiver->id].mode].nb=0;
mode_settings[vfo[active_receiver->id].mode].nb2=1;
} else if(active_receiver->nb==0 && active_receiver->nb2==1) {
active_receiver->nb=0;
active_receiver->nb2=0;
mode_settings[vfo[active_receiver->id].mode].nb=0;
mode_settings[vfo[active_receiver->id].mode].nb2=0;
}
update_noise();
return 0;
}
int ext_snb_update(void *data) {
if(active_receiver->snb==0) {
active_receiver->snb=1;
mode_settings[vfo[active_receiver->id].mode].snb=1;
} else {
active_receiver->snb=0;
mode_settings[vfo[active_receiver->id].mode].snb=0;
}
update_noise();
return 0;
}
void band_plus(int id) {
long long frequency_min=radio->frequency_min;
long long frequency_max=radio->frequency_max;
int b=vfo[id].band;
BAND *band;
int found=0;
while(!found) {
b++;
if(b>=BANDS+XVTRS) b=0;
band=(BAND*)band_get_band(b);
if(strlen(band->title)>0) {
if(b<BANDS) {
if(!(band->frequencyMin==0.0 && band->frequencyMax==0.0)) {
if(band->frequencyMin<frequency_min || band->frequencyMax>frequency_max) {
continue;
}
}
}
vfo_band_changed(id,b);
found=1;
}
}
}
int ext_band_select(void *data) {
int b=GPOINTER_TO_INT(data);
vfo_band_changed(active_receiver->id,b);
return 0;
}
int ext_band_plus(void *data) {
band_plus(active_receiver->id);
return 0;
}
void band_minus(int id) {
long long frequency_min=radio->frequency_min;
long long frequency_max=radio->frequency_max;
int b=vfo[id].band;
BAND *band;
int found=0;
while(!found) {
b--;
if(b<0) b=BANDS+XVTRS-1;
band=(BAND*)band_get_band(b);
if(strlen(band->title)>0) {
if(b<BANDS) {
if(band->frequencyMin<frequency_min || band->frequencyMax>frequency_max) {
continue;
}
}
vfo_band_changed(id,b);
found=1;
}
}
}
int ext_band_minus(void *data) {
band_minus(active_receiver->id);
return 0;
}
int ext_bandstack_plus(void *data) {
BAND *band=band_get_band(vfo[active_receiver->id].band);
BANDSTACK *bandstack=band->bandstack;
int b=vfo[active_receiver->id].bandstack+1;
if(b>=bandstack->entries) b=0;
vfo_bandstack_changed(b);
return 0;
}
int ext_bandstack_minus(void *data) {
BAND *band=band_get_band(vfo[active_receiver->id].band);
BANDSTACK *bandstack=band->bandstack;
int b=vfo[active_receiver->id].bandstack-1;
if(b<0) b=bandstack->entries-1;;
vfo_bandstack_changed(b);
return 0;
}
int ext_lock_update(void *data) {
#ifdef CLIENT_SERVER
if(radio_is_remote) {
send_lock(client_socket,locked==1?0:1);
} else {
#endif
locked=locked==1?0:1;
g_idle_add(ext_vfo_update, NULL);
#ifdef CLIENT_SERVER
}
#endif
return 0;
}
int ext_rit_update(void *data) {
vfo_rit_update(active_receiver->id);
return 0;
}
int ext_rit_clear(void *data) {
vfo_rit_clear(active_receiver->id);
return 0;
}
int ext_xit_update(void *data) {
if(can_transmit) {
transmitter->xit_enabled=transmitter->xit_enabled==1?0:1;
if(protocol==NEW_PROTOCOL) {
schedule_high_priority();
}
}
g_idle_add(ext_vfo_update, NULL);
return 0;
}
int ext_xit_clear(void *data) {
if(can_transmit) {
transmitter->xit=0;
g_idle_add(ext_vfo_update, NULL);
}
return 0;
}
int ext_filter_plus(void *data) {
int f=vfo[active_receiver->id].filter-1;
if(f<0) f=FILTERS-1;
vfo_filter_changed(f);
return 0;
}
int ext_filter_minus(void *data) {
int f=vfo[active_receiver->id].filter+1;
if(f>=FILTERS) f=0;
vfo_filter_changed(f);
return 0;
}
int ext_mode_plus(void *data) {
int mode=vfo[active_receiver->id].mode;
mode++;
if(mode>=MODES) mode=0;
vfo_mode_changed(mode);
return 0;
}
int ext_mode_minus(void *data) {
int mode=vfo[active_receiver->id].mode;
mode--;
if(mode<0) mode=MODES-1;
vfo_mode_changed(mode);
return 0;
}
void ctun_update(int id,int state) {
vfo[id].ctun=state;
if(!vfo[id].ctun) {
vfo[id].offset=0;
}
vfo[id].ctun_frequency=vfo[id].frequency;
set_offset(receiver[id],vfo[id].offset);
}
int ext_ctun_update(void *data) {
ctun_update(active_receiver->id,vfo[active_receiver->id].ctun==1?0:1);
g_idle_add(ext_vfo_update, NULL);
return 0;
}
int ext_agc_update(void *data) {
active_receiver->agc++;
if(active_receiver->agc>+AGC_LAST) {
active_receiver->agc=0;
}
set_agc(active_receiver, active_receiver->agc);
g_idle_add(ext_vfo_update, NULL);
return 0;
}
int ext_split_toggle(void *data) {
if(can_transmit) {
split=split==1?0:1;
tx_set_mode(transmitter,get_tx_mode());
g_idle_add(ext_vfo_update, NULL);
}
return 0;
}
int ext_start_rx(void *data) {
start_rx();
return 0;
}
int ext_start_tx(void *data) {
start_tx();
return 0;
}
int ext_diversity_update(void *data) {
int menu=GPOINTER_TO_INT(data);
if(menu) {
start_diversity();
} else {
diversity_enabled=diversity_enabled==1?0:1;
if (protocol == NEW_PROTOCOL) {
schedule_high_priority();
schedule_receive_specific();
}
g_idle_add(ext_vfo_update, NULL);
}
return 0;
}
int ext_diversity_change_gain(void *data) {
double *dp = (double *) data;
update_diversity_gain(*dp);
free(dp);
return 0;
}
int ext_diversity_change_phase(void *data) {
double *dp = (double *) data;
update_diversity_phase(*dp);
free(dp);
return 0;
}
#ifdef PURESIGNAL
int ext_start_ps(void *data) {
start_ps();
return 0;
}
#endif
int ext_sat_update(void *data) {
switch(sat_mode) {
case SAT_NONE:
sat_mode=SAT_MODE;
break;
case SAT_MODE:
sat_mode=RSAT_MODE;
break;
case RSAT_MODE:
sat_mode=SAT_NONE;
break;
}
g_idle_add(ext_vfo_update, NULL);
return 0;
}
int ext_function_update(void *data) {
function++;
if(function>MAX_FUNCTION) {
function=0;
}
update_toolbar_labels();
g_idle_add(ext_vfo_update, NULL);
return 0;
}
int ext_set_rf_gain(void *data) {
int pos=GPOINTER_TO_INT(data);
double value;
value=(double)pos;
if(value<-12.0) {
value=-12.0;
} else if(value>48.0) {
value=48.0;
}
set_rf_gain(active_receiver->id,value);
return 0;
}
int ext_update_noise(void *data) {
update_noise();
return 0;
}
int ext_set_duplex(void *data) {
setDuplex();
return 0;
}
#ifdef CLIENT_SERVER
int ext_remote_command(void *data) {
HEADER *header=(HEADER *)data;
REMOTE_CLIENT *client=header->context.client;
int temp;
switch(ntohs(header->data_type)) {
case CMD_RESP_RX_FREQ:
{
FREQ_COMMAND *freq_command=(FREQ_COMMAND *)data;
temp=active_receiver->pan;
int vfo=freq_command->id;
long long f=ntohll(freq_command->hz);
local_set_frequency(vfo,f);
vfo_update();
send_vfo_data(client,VFO_A);
send_vfo_data(client,VFO_B);
if(temp!=active_receiver->pan) {
send_pan(client->socket,active_receiver->id,active_receiver->pan);
}
}
break;
case CMD_RESP_RX_STEP:
{
STEP_COMMAND *step_command=(STEP_COMMAND *)data;
temp=active_receiver->pan;
short steps=ntohs(step_command->steps);
vfo_step(steps);
//send_vfo_data(client,VFO_A);
//send_vfo_data(client,VFO_B);
if(temp!=active_receiver->pan) {
send_pan(client->socket,active_receiver->id,active_receiver->pan);
}
}
break;
case CMD_RESP_RX_MOVE:
{
MOVE_COMMAND *move_command=(MOVE_COMMAND *)data;
temp=active_receiver->pan;
long long hz=ntohll(move_command->hz);
vfo_move(hz,move_command->round);
//send_vfo_data(client,VFO_A);
//send_vfo_data(client,VFO_B);
if(temp!=active_receiver->pan) {
send_pan(client->socket,active_receiver->id,active_receiver->pan);
}
}
break;
case CMD_RESP_RX_MOVETO:
{
MOVE_TO_COMMAND *move_to_command=(MOVE_TO_COMMAND *)data;
temp=active_receiver->pan;
long long hz=ntohll(move_to_command->hz);
vfo_move_to(hz);
send_vfo_data(client,VFO_A);
send_vfo_data(client,VFO_B);
if(temp!=active_receiver->pan) {
send_pan(client->socket,active_receiver->id,active_receiver->pan);
}
}
break;
case CMD_RESP_RX_ZOOM:
{
ZOOM_COMMAND *zoom_command=(ZOOM_COMMAND *)data;
temp=ntohs(zoom_command->zoom);
set_zoom(zoom_command->id,(double)temp);
send_zoom(client->socket,active_receiver->id,active_receiver->zoom);
send_pan(client->socket,active_receiver->id,active_receiver->pan);
}
break;
case CMD_RESP_RX_PAN:
{
PAN_COMMAND *pan_command=(PAN_COMMAND *)data;
temp=ntohs(pan_command->pan);
set_pan(pan_command->id,(double)temp);
send_pan(client->socket,active_receiver->id,active_receiver->pan);
}
break;
case CMD_RESP_RX_VOLUME:
{
VOLUME_COMMAND *volume_command=(VOLUME_COMMAND *)data;
temp=ntohs(volume_command->volume);
set_af_gain(volume_command->id,(double)temp/100.0);
}
break;
case CMD_RESP_RX_AGC:
{
AGC_COMMAND *agc_command=(AGC_COMMAND *)data;
RECEIVER *rx=receiver[agc_command->id];
rx->agc=ntohs(agc_command->agc);
set_agc(rx,rx->agc);
send_agc(client->socket,rx->id,rx->agc);
g_idle_add(ext_vfo_update, NULL);
}
break;
case CMD_RESP_RX_AGC_GAIN:
{
AGC_GAIN_COMMAND *agc_gain_command=(AGC_GAIN_COMMAND *)data;
temp=ntohs(agc_gain_command->gain);
set_agc_gain(agc_gain_command->id,(double)temp);
RECEIVER *rx=receiver[agc_gain_command->id];
send_agc_gain(client->socket,rx->id,(int)rx->agc_gain,(int)rx->agc_hang,(int)rx->agc_thresh);
}
break;
case CMD_RESP_RX_GAIN:
{
RFGAIN_COMMAND *command=(RFGAIN_COMMAND *) data;
double td=ntohd(command->gain);
set_rf_gain(command->id, td);
}
break;
case CMD_RESP_RX_ATTENUATION:
{
ATTENUATION_COMMAND *attenuation_command=(ATTENUATION_COMMAND *)data;
temp=ntohs(attenuation_command->attenuation);
set_attenuation(temp);
}
break;
case CMD_RESP_RX_SQUELCH:
{
SQUELCH_COMMAND *squelch_command=(SQUELCH_COMMAND *)data;
receiver[squelch_command->id]->squelch_enable=squelch_command->enable;
temp=ntohs(squelch_command->squelch);
receiver[squelch_command->id]->squelch=(double)temp;
set_squelch(receiver[squelch_command->id]);
}
break;
case CMD_RESP_RX_NOISE:
{
NOISE_COMMAND *noise_command=(NOISE_COMMAND *)data;
RECEIVER *rx=receiver[noise_command->id];
rx->nb=noise_command->nb;
rx->nb2=noise_command->nb2;
mode_settings[vfo[rx->id].mode].nb=rx->nb;
mode_settings[vfo[rx->id].mode].nb2=rx->nb2;
rx->nr=noise_command->nr;
rx->nr2=noise_command->nr2;
mode_settings[vfo[rx->id].mode].nr=rx->nr;
mode_settings[vfo[rx->id].mode].nr2=rx->nr2;
rx->anf=noise_command->anf;
mode_settings[vfo[rx->id].mode].anf=rx->anf;
rx->snb=noise_command->snb;
mode_settings[vfo[rx->id].mode].snb=rx->snb;
set_noise();
send_noise(client->socket,rx->id,rx->nb,rx->nb2,rx->nr,rx->nr2,rx->anf,rx->snb);
}
break;
case CMD_RESP_RX_BAND:
{
BAND_COMMAND *band_command=(BAND_COMMAND *)data;
RECEIVER *rx=receiver[band_command->id];
short b=htons(band_command->band);
vfo_band_changed(rx->id,b);
send_vfo_data(client,VFO_A);
send_vfo_data(client,VFO_B);
}
break;
case CMD_RESP_RX_MODE:
{
MODE_COMMAND *mode_command=(MODE_COMMAND *)data;
RECEIVER *rx=receiver[mode_command->id];
short m=htons(mode_command->mode);
vfo_mode_changed(m);
send_vfo_data(client,VFO_A);
send_vfo_data(client,VFO_B);
send_filter(client->socket,rx->id,m);
}
break;
case CMD_RESP_RX_FILTER:
{
FILTER_COMMAND *filter_command=(FILTER_COMMAND *)data;
RECEIVER *rx=receiver[filter_command->id];
short f=htons(filter_command->filter);
vfo_filter_changed(f);
send_vfo_data(client,VFO_A);
send_vfo_data(client,VFO_B);
send_filter(client->socket,rx->id,f);
}
break;
case CMD_RESP_SPLIT:
{
SPLIT_COMMAND *split_command=(SPLIT_COMMAND *)data;
if(can_transmit) {
split=split_command->split;
tx_set_mode(transmitter,get_tx_mode());
g_idle_add(ext_vfo_update, NULL);
}
send_split(client->socket,split);
}
break;
case CMD_RESP_SAT:
{
SAT_COMMAND *sat_command=(SAT_COMMAND *)data;
sat_mode=sat_command->sat;
g_idle_add(ext_vfo_update, NULL);
send_sat(client->socket,sat_mode);
}
break;
case CMD_RESP_DUP:
{
DUP_COMMAND *dup_command=(DUP_COMMAND *)data;
duplex=dup_command->dup;
g_idle_add(ext_vfo_update, NULL);
send_dup(client->socket,duplex);
}
break;
case CMD_RESP_LOCK:
{
LOCK_COMMAND *lock_command=(LOCK_COMMAND *)data;
locked=lock_command->lock;
g_idle_add(ext_vfo_update, NULL);
send_lock(client->socket,locked);
}
break;
case CMD_RESP_CTUN:
{
CTUN_COMMAND *ctun_command=(CTUN_COMMAND *)data;
int v=ctun_command->id;
vfo[v].ctun=ctun_command->ctun;
if(!vfo[v].ctun) {
vfo[v].offset=0;
}
vfo[v].ctun_frequency=vfo[v].frequency;
set_offset(active_receiver,vfo[v].offset);
g_idle_add(ext_vfo_update, NULL);
send_ctun(client->socket,v,vfo[v].ctun);
send_vfo_data(client,v);
}
break;
case CMD_RESP_RX_FPS:
{
FPS_COMMAND *fps_command=(FPS_COMMAND *)data;
int rx=fps_command->id;
receiver[rx]->fps=fps_command->fps;
calculate_display_average(receiver[rx]);
set_displaying(receiver[rx],1);
send_fps(client->socket,rx,receiver[rx]->fps);
}
break;
case CMD_RESP_RX_SELECT:
{
RX_SELECT_COMMAND *rx_select_command=(RX_SELECT_COMMAND *)data;
int rx=rx_select_command->id;
receiver_set_active(receiver[rx]);
send_rx_select(client->socket,rx);
}
break;
case CMD_RESP_VFO:
{
VFO_COMMAND *vfo_command=(VFO_COMMAND *)data;
int action=vfo_command->id;
switch(action) {
case VFO_A_TO_B:
vfo_a_to_b();
break;
case VFO_B_TO_A:
vfo_b_to_a();
break;
case VFO_A_SWAP_B:
vfo_a_swap_b();
break;
}
send_vfo_data(client,VFO_A);
send_vfo_data(client,VFO_B);
}
break;
case CMD_RESP_RIT_UPDATE:
{
RIT_UPDATE_COMMAND *rit_update_command=(RIT_UPDATE_COMMAND *)data;
int rx=rit_update_command->id;
vfo_rit_update(rx);
send_vfo_data(client,rx);
}
break;
case CMD_RESP_RIT_CLEAR:
{
RIT_CLEAR_COMMAND *rit_clear_command=(RIT_CLEAR_COMMAND *)data;
int rx=rit_clear_command->id;
vfo_rit_clear(rx);
send_vfo_data(client,rx);
}
break;
case CMD_RESP_RIT:
{
RIT_COMMAND *rit_command=(RIT_COMMAND *)data;
int rx=rit_command->id;