@@ -65,14 +65,12 @@ void StackchanSystemConfig::setDefaultParameters() {
65
65
_servo[AXIS_X].start_degree = 90 ;
66
66
_servo[AXIS_Y].start_degree = 90 ;
67
67
_secret_config_show = false ;
68
- _extend_config_filename = " " ;
69
- _extend_config_filesize = 0 ;
70
- _secret_config_filename = " " ;
71
- _secret_config_filesize = 0 ;
72
68
73
69
}
74
70
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) {
76
74
M5_LOGI (" ----- StackchanSystemConfig::loadConfig:%s\n " , basic_yaml_filename);
77
75
M5_LOGI (" ----- app_yaml_filename:%s\n " , app_yaml_filename);
78
76
fs::File file = fs.open (basic_yaml_filename);
@@ -89,11 +87,12 @@ void StackchanSystemConfig::loadConfig(fs::FS& fs, const char *app_yaml_filename
89
87
Serial.println (" ConfigFile Not Found. Default Parameters used." );
90
88
// YAMLファイルが見つからない場合はデフォルト値を利用します。
91
89
setDefaultParameters ();
90
+ basicConfigNotFoundCallback ();
92
91
}
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 );
95
94
}
96
- if (_extend_config_filesize > 0 ) {
95
+ if (app_yaml_filename > 0 ) {
97
96
loadExtendConfig (fs, app_yaml_filename, app_yaml_filesize);
98
97
}
99
98
printAllParameters ();
@@ -109,19 +108,26 @@ void StackchanSystemConfig::loadSecretConfig(fs::FS& fs, const char* yaml_filena
109
108
M5_LOGE (" yaml file read error: %s\n " , yaml_filename);
110
109
M5_LOGE (" error%s\n " , err.c_str ());
111
110
}
111
+ else {
112
+ setSecretConfig (doc);
113
+ }
114
+
112
115
if (_secret_config_show) {
113
116
// 個人的な情報をログに表示する。
114
117
M5_LOGI (" =======================================================================================" );
115
118
M5_LOGI (" 下記の情報は公開してはいけません。(The following information must not be disclosed.)" );
116
119
M5_LOGI (" " );
117
120
serializeJsonPretty (doc, Serial);
118
- setSecretConfig (doc);
119
121
M5_LOGI (" " );
120
122
printSecretParameters ();
123
+ M5_LOGI (" " );
121
124
M5_LOGI (" ここまでの情報は公開してはいけません。(No information should be disclosed so far.)" );
122
125
M5_LOGI (" =======================================================================================" );
123
126
}
124
127
}
128
+ else {
129
+ secretConfigNotFoundCallback ();
130
+ }
125
131
}
126
132
127
133
void StackchanSystemConfig::setSystemConfig (DynamicJsonDocument doc) {
@@ -176,10 +182,6 @@ void StackchanSystemConfig::setSystemConfig(DynamicJsonDocument doc) {
176
182
_servo[AXIS_Y].start_degree = 90 ;
177
183
}
178
184
_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" ];
183
185
}
184
186
185
187
void StackchanSystemConfig::setSecretConfig (DynamicJsonDocument doc) {
@@ -230,10 +232,6 @@ void StackchanSystemConfig::printAllParameters() {
230
232
M5_LOGI (" use takao_base:%s" , _takao_base ? " true" :" false" );
231
233
M5_LOGI (" ServoTypeStr:%s" , _servo_type_str.c_str ());
232
234
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);
237
235
M5_LOGI (" secret_config_show:%s" , _secret_config_show ? " true" :" false" );
238
236
239
237
printExtParameters ();
@@ -247,6 +245,10 @@ void StackchanSystemConfig::printSecretParameters() {
247
245
M5_LOGI (" apikey_tts: %s" , _secret_config.api_key .tts .c_str ());
248
246
}
249
247
void 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) { };
251
249
void StackchanSystemConfig::printExtParameters (void ) {};
250
+
251
+ void StackchanSystemConfig::basicConfigNotFoundCallback (void ) {};
252
+ void StackchanSystemConfig::secretConfigNotFoundCallback (void ) {};
253
+
252
254
#endif
0 commit comments