@@ -125,6 +125,8 @@ static channel_id_t default_channel_id = {
125
125
126
126
static channel_id_t current_channel_id = EMPTY_CHANNEL_ID ;
127
127
128
+ static uint8_t gain_offset = 0 ;
129
+
128
130
/*
129
131
* FSK packet handler structure
130
132
*/
@@ -361,10 +363,8 @@ uint16_t phy_calculate_tx_duration(phy_channel_class_t channel_class, phy_coding
361
363
362
364
static void configure_eirp (eirp_t eirp )
363
365
{
364
- int8_t factory_settings [D7A_FILE_FACTORY_SETTINGS_SIZE ]; //Byte 0 is gain offset
365
- d7ap_fs_read_file (D7A_FILE_FACTORY_SETTINGS_FILE_ID , 0 , factory_settings , D7A_FILE_FACTORY_SETTINGS_SIZE );
366
- eirp -= factory_settings [0 ];
367
- DPRINT ("Set Tx power: %d dBm including offset of %i\n" , eirp , factory_settings [0 ]);
366
+ eirp -= gain_offset ;
367
+ DPRINT ("Set Tx power: %d dBm including offset of %i\n" , eirp , gain_offset );
368
368
369
369
hw_radio_set_tx_power (eirp );
370
370
}
@@ -443,6 +443,16 @@ void continuous_tx_expiration()
443
443
DPRINT ("Continuous TX is now terminated" );
444
444
}
445
445
446
+ void fact_settings_file_change_callback ()
447
+ {
448
+ uint8_t fact_settings [D7A_FILE_FACTORY_SETTINGS_SIZE ];
449
+ d7ap_fs_read_file (D7A_FILE_FACTORY_SETTINGS_FILE_ID , 0 , fact_settings , D7A_FILE_FACTORY_SETTINGS_SIZE );
450
+
451
+ gain_offset = (int8_t )fact_settings [0 ];
452
+
453
+ DPRINT ("gain set to %i\n" , gain_offset );
454
+ }
455
+
446
456
447
457
error_t phy_init (void ) {
448
458
@@ -469,6 +479,10 @@ error_t phy_init(void) {
469
479
hw_radio_set_dc_free (HW_DC_FREE_NONE );
470
480
#endif
471
481
482
+ fact_settings_file_change_callback ();
483
+
484
+ d7ap_fs_register_file_modified_callback (D7A_FILE_FACTORY_SETTINGS_FILE_ID , & fact_settings_file_change_callback );
485
+
472
486
configure_syncword (PHY_SYNCWORD_CLASS0 , & default_channel_id );
473
487
configure_channel (& default_channel_id );
474
488
configure_eirp (10 );
0 commit comments