@@ -65,14 +65,12 @@ void StackchanSystemConfig::setDefaultParameters() {
6565 _servo[AXIS_X].start_degree = 90 ;
6666 _servo[AXIS_Y].start_degree = 90 ;
6767 _secret_config_show = false ;
68- _extend_config_filename = " " ;
69- _extend_config_filesize = 0 ;
70- _secret_config_filename = " " ;
71- _secret_config_filesize = 0 ;
7268
7369}
7470
75- void StackchanSystemConfig::loadConfig (fs::FS& fs, const char *app_yaml_filename, uint32_t app_yaml_filesize, const char * basic_yaml_filename, uint32_t basic_yaml_filesize) {
71+ void StackchanSystemConfig::loadConfig (fs::FS& fs, const char *app_yaml_filename, uint32_t app_yaml_filesize,
72+ const char * secret_yaml_filename, uint32_t secret_yaml_filesize,
73+ const char * basic_yaml_filename, uint32_t basic_yaml_filesize) {
7674 M5_LOGI (" ----- StackchanSystemConfig::loadConfig:%s\n " , basic_yaml_filename);
7775 M5_LOGI (" ----- app_yaml_filename:%s\n " , app_yaml_filename);
7876 fs::File file = fs.open (basic_yaml_filename);
@@ -89,11 +87,12 @@ void StackchanSystemConfig::loadConfig(fs::FS& fs, const char *app_yaml_filename
8987 Serial.println (" ConfigFile Not Found. Default Parameters used." );
9088 // YAMLファイルが見つからない場合はデフォルト値を利用します。
9189 setDefaultParameters ();
90+ basicConfigNotFoundCallback ();
9291 }
93- if (_secret_config_filesize > 0 ) {
94- loadSecretConfig (fs, _secret_config_filename. c_str (), _secret_config_filesize );
92+ if (secret_yaml_filesize > 0 ) {
93+ loadSecretConfig (fs, secret_yaml_filename, secret_yaml_filesize );
9594 }
96- if (_extend_config_filesize > 0 ) {
95+ if (app_yaml_filename > 0 ) {
9796 loadExtendConfig (fs, app_yaml_filename, app_yaml_filesize);
9897 }
9998 printAllParameters ();
@@ -109,19 +108,26 @@ void StackchanSystemConfig::loadSecretConfig(fs::FS& fs, const char* yaml_filena
109108 M5_LOGE (" yaml file read error: %s\n " , yaml_filename);
110109 M5_LOGE (" error%s\n " , err.c_str ());
111110 }
111+ else {
112+ setSecretConfig (doc);
113+ }
114+
112115 if (_secret_config_show) {
113116 // 個人的な情報をログに表示する。
114117 M5_LOGI (" =======================================================================================" );
115118 M5_LOGI (" 下記の情報は公開してはいけません。(The following information must not be disclosed.)" );
116119 M5_LOGI (" " );
117120 serializeJsonPretty (doc, Serial);
118- setSecretConfig (doc);
119121 M5_LOGI (" " );
120122 printSecretParameters ();
123+ M5_LOGI (" " );
121124 M5_LOGI (" ここまでの情報は公開してはいけません。(No information should be disclosed so far.)" );
122125 M5_LOGI (" =======================================================================================" );
123126 }
124127 }
128+ else {
129+ secretConfigNotFoundCallback ();
130+ }
125131}
126132
127133void StackchanSystemConfig::setSystemConfig (DynamicJsonDocument doc) {
@@ -176,10 +182,6 @@ void StackchanSystemConfig::setSystemConfig(DynamicJsonDocument doc) {
176182 _servo[AXIS_Y].start_degree = 90 ;
177183 }
178184 _secret_config_show = doc[" secret_config_show" ].as <bool >();
179- _secret_config_filename = doc[" secret_config_filename" ].as <String>();
180- _secret_config_filesize = doc[" secret_config_filesize" ];
181- _extend_config_filename = doc[" extend_config_filename" ].as <String>();
182- _extend_config_filesize = doc[" extend_config_filesize" ];
183185}
184186
185187void StackchanSystemConfig::setSecretConfig (DynamicJsonDocument doc) {
@@ -230,10 +232,6 @@ void StackchanSystemConfig::printAllParameters() {
230232 M5_LOGI (" use takao_base:%s" , _takao_base ? " true" :" false" );
231233 M5_LOGI (" ServoTypeStr:%s" , _servo_type_str.c_str ());
232234 M5_LOGI (" ServoType: %d" , _servo_type);
233- M5_LOGI (" SecretConfigFileName: %s" , _secret_config_filename.c_str ());
234- M5_LOGI (" SecretConfigFileSize: %d" , _secret_config_filesize);
235- M5_LOGI (" ExtendConfigFileName: %s" , _extend_config_filename.c_str ());
236- M5_LOGI (" ExtendConfigFileSize: %d" , _extend_config_filesize);
237235 M5_LOGI (" secret_config_show:%s" , _secret_config_show ? " true" :" false" );
238236
239237 printExtParameters ();
@@ -247,6 +245,10 @@ void StackchanSystemConfig::printSecretParameters() {
247245 M5_LOGI (" apikey_tts: %s" , _secret_config.api_key .tts .c_str ());
248246}
249247void StackchanSystemConfig::loadExtendConfig (fs::FS& fs, const char * filename, uint32_t yaml_size) { };
250- void StackchanSystemConfig::setExtendSettings (DynamicJsonDocument doc) { if ( _extend_config_filename == " " ) return ; };
248+ void StackchanSystemConfig::setExtendSettings (DynamicJsonDocument doc) { };
251249void StackchanSystemConfig::printExtParameters (void ) {};
250+
251+ void StackchanSystemConfig::basicConfigNotFoundCallback (void ) {};
252+ void StackchanSystemConfig::secretConfigNotFoundCallback (void ) {};
253+
252254#endif
0 commit comments