@@ -64,8 +64,12 @@ void StackchanSystemConfig::setDefaultParameters() {
64
64
_servo_type = 0 ;
65
65
_servo[AXIS_X].start_degree = 90 ;
66
66
_servo[AXIS_Y].start_degree = 90 ;
67
+ _secret_config_show = false ;
67
68
_extend_config_filename = " " ;
68
69
_extend_config_filesize = 0 ;
70
+ _secret_config_filename = " " ;
71
+ _secret_config_filesize = 0 ;
72
+
69
73
}
70
74
71
75
void StackchanSystemConfig::loadConfig (fs::FS& fs, const char *yaml_filename) {
@@ -85,12 +89,40 @@ void StackchanSystemConfig::loadConfig(fs::FS& fs, const char *yaml_filename) {
85
89
// JSONファイルが見つからない場合はデフォルト値を利用します。
86
90
setDefaultParameters ();
87
91
}
88
- if (_extend_config_filesize >= 0 ) {
92
+ if (_secret_config_filename > 0 ) {
93
+ loadSecretConfig (fs, _secret_config_filename.c_str (), _secret_config_filesize);
94
+ }
95
+ if (_extend_config_filesize > 0 ) {
89
96
loadExtendConfig (fs, _extend_config_filename.c_str (), _extend_config_filesize);
90
97
}
91
98
printAllParameters ();
92
99
}
93
100
101
+ void StackchanSystemConfig::loadSecretConfig (fs::FS& fs, const char * yaml_filename, uint32_t yaml_size) {
102
+ M5_LOGI (" ----- StackchanSecretConfig::loadConfig:%s\n " , yaml_filename);
103
+ File file = fs.open (yaml_filename);
104
+ if (file) {
105
+ DynamicJsonDocument doc (yaml_size);
106
+ auto err = deserializeYml ( doc, file);
107
+ if (err) {
108
+ M5_LOGE (" yaml file read error: %s\n " , yaml_filename);
109
+ M5_LOGE (" error%s\n " , err.c_str ());
110
+ }
111
+ if (_secret_info_show) {
112
+ // 個人的な情報をログに表示する。
113
+ M5_LOGI (" =======================================================================================" );
114
+ M5_LOGI (" 下記の情報は公開してはいけません。(The following information must not be disclosed.)" );
115
+ M5_LOGI (" " );
116
+ serializeJsonPretty (doc, Serial);
117
+ setSecretSettings (doc);
118
+ M5_LOGI (" " );
119
+ printSecretParameters ();
120
+ M5_LOGI (" ここまでの情報は公開してはいけません。(No information should be disclosed so far.)" );
121
+ M5_LOGI (" =======================================================================================" );
122
+ }
123
+ }
124
+ }
125
+
94
126
void StackchanSystemConfig::setSystemConfig (DynamicJsonDocument doc) {
95
127
JsonObject servo = doc[" servo" ];
96
128
_servo[AXIS_X].pin = servo[" pin" ][" x" ];
@@ -118,9 +150,6 @@ void StackchanSystemConfig::setSystemConfig(DynamicJsonDocument doc) {
118
150
_bluetooth.starting_state = doc[" bluetooth" ][" starting_state" ];// .as<bool>();
119
151
_bluetooth.start_volume = doc[" bluetooth" ][" start_volume" ];
120
152
121
- _wifi.ssid = doc[" wifi" ][" ssid" ].as <String>();
122
- _wifi.password = doc[" wifi" ][" password" ].as <String>();
123
-
124
153
_auto_power_off_time = doc[" auto_power_off_time" ];
125
154
_font_language_code = doc[" balloon" ][" font_language" ].as <String>();
126
155
@@ -145,10 +174,21 @@ void StackchanSystemConfig::setSystemConfig(DynamicJsonDocument doc) {
145
174
_servo[AXIS_X].start_degree = 90 ;
146
175
_servo[AXIS_Y].start_degree = 90 ;
147
176
}
148
-
177
+ _secret_info_show = doc[" sercret_info_show" ].as <bool >();
178
+ _secret_config_filename = doc[" secret_config_filename" ].as <String>();
179
+ _secret_config_filesize = doc[" secret_config_filesize" ];
149
180
_extend_config_filename = doc[" extend_config_filename" ].as <String>();
150
181
_extend_config_filesize = doc[" extend_config_filesize" ];
182
+ }
151
183
184
+ void StackchanSystemConfig::setSecretConfig (DynamicJsonDocument doc) {
185
+
186
+ _secret_config.wifi_info .ssid = doc[" wifi" ][" ssid" ].as <String>();
187
+ _secret_config.wifi_info .password = doc[" wifi" ][" password" ].as <String>();
188
+
189
+ _secret_config.apikey .stt = doc[" apikey" ][" stt" ].as <String>();
190
+ _secret_config.apikey .aiservice = doc[" apikey" ][" aiservice" ].as <String>();
191
+ _secret_config.apikey .tts = doc[" apikey" ][" tts" ].as <String>();
152
192
153
193
}
154
194
@@ -164,39 +204,48 @@ const lgfx::IFont* StackchanSystemConfig::getFont() {
164
204
}
165
205
166
206
void StackchanSystemConfig::printAllParameters () {
167
- M5_LOGI (" servo:pin_x:%d\n " , _servo[AXIS_X].pin );
168
- M5_LOGI (" servo:pin_y:%d\n " , _servo[AXIS_Y].pin );
169
- M5_LOGI (" servo:offset_x:%d\n " , _servo[AXIS_X].offset );
170
- M5_LOGI (" servo:offset_y:%d\n " , _servo[AXIS_Y].offset );
207
+ M5_LOGI (" servo:pin_x:%d" , _servo[AXIS_X].pin );
208
+ M5_LOGI (" servo:pin_y:%d" , _servo[AXIS_Y].pin );
209
+ M5_LOGI (" servo:offset_x:%d" , _servo[AXIS_X].offset );
210
+ M5_LOGI (" servo:offset_y:%d" , _servo[AXIS_Y].offset );
171
211
for (int i=0 ;i<_mode_num;i++) {
172
- M5_LOGI (" mode:%s\n " , _servo_interval[i].mode_name );
173
- M5_LOGI (" interval_min:%d\n " , _servo_interval[i].interval_min );
174
- M5_LOGI (" interval_max:%d\n " , _servo_interval[i].interval_max );
175
- M5_LOGI (" move_min:%d\n " , _servo_interval[i].move_min );
176
- M5_LOGI (" move_max:%d\n " , _servo_interval[i].move_max );
212
+ M5_LOGI (" mode:%s" , _servo_interval[i].mode_name );
213
+ M5_LOGI (" interval_min:%d" , _servo_interval[i].interval_min );
214
+ M5_LOGI (" interval_max:%d" , _servo_interval[i].interval_max );
215
+ M5_LOGI (" move_min:%d" , _servo_interval[i].move_min );
216
+ M5_LOGI (" move_max:%d" , _servo_interval[i].move_max );
177
217
}
178
- M5_LOGI (" mode_num:%d\n " , _mode_num);
179
- M5_LOGI (" WiFi SSID: %s\n " , _wifi.ssid .c_str ());
180
- M5_LOGI (" WiFi PASS: %s\n " , _wifi.password .c_str ());
181
- M5_LOGI (" Bluetooth_device_name:%s\n " , _bluetooth.device_name .c_str ());
182
- M5_LOGI (" Bluetooth_starting_state:%s\n " , _bluetooth.starting_state ? " true" :" false" );
183
- M5_LOGI (" Bluetooth_start_volume:%d\n " , _bluetooth.start_volume );
184
- M5_LOGI (" auto_power_off_time:%d\n " , _auto_power_off_time);
185
- M5_LOGI (" font_language:%s\n " , _font_language_code);
218
+ M5_LOGI (" mode_num:%d" , _mode_num);
219
+ M5_LOGI (" WiFi SSID: %s" , _wifi.ssid .c_str ());
220
+ M5_LOGI (" WiFi PASS: %s" , _wifi.password .c_str ());
221
+ M5_LOGI (" Bluetooth_device_name:%s" , _bluetooth.device_name .c_str ());
222
+ M5_LOGI (" Bluetooth_starting_state:%s" , _bluetooth.starting_state ? " true" :" false" );
223
+ M5_LOGI (" Bluetooth_start_volume:%d" , _bluetooth.start_volume );
224
+ M5_LOGI (" auto_power_off_time:%d" , _auto_power_off_time);
225
+ M5_LOGI (" font_language:%s" , _font_language_code);
186
226
for (int i=0 ;i<_lyrics_num;i++) {
187
- M5_LOGI (" lyrics:%d:%s\n " , i, _lyrics[i].c_str ());
227
+ M5_LOGI (" lyrics:%d:%s" , i, _lyrics[i].c_str ());
188
228
}
189
- M5_LOGI (" led_lr:%d\n " , _led_lr);
190
- M5_LOGI (" led_pin:%d\n " , _led_pin);
191
- M5_LOGI (" use takao_base:%s\n " , _takao_base ? " true" :" false" );
192
- M5_LOGI (" ServoTypeStr:%s\n " , _servo_type_str.c_str ());
193
- M5_LOGI (" ServoType: %d\n " , _servo_type);
194
- M5_LOGI (" ExtendConfigFileName: %s\n " , _extend_config_filename.c_str ());
195
- M5_LOGI (" ExtendConfigFileSize: %d\n " , _extend_config_filesize);
229
+ M5_LOGI (" led_lr:%d" , _led_lr);
230
+ M5_LOGI (" led_pin:%d" , _led_pin);
231
+ M5_LOGI (" use takao_base:%s" , _takao_base ? " true" :" false" );
232
+ M5_LOGI (" ServoTypeStr:%s" , _servo_type_str.c_str ());
233
+ M5_LOGI (" ServoType: %d" , _servo_type);
234
+ M5_LOGI (" SecretConfigFileName: %s" , _secret_config_filename.c_str ());
235
+ M5_LOGI (" SecretConfigFileSize: %d" , _secret_config_filesize);
236
+ M5_LOGI (" ExtendConfigFileName: %s" , _extend_config_filename.c_str ());
237
+ M5_LOGI (" ExtendConfigFileSize: %d" , _extend_config_filesize);
196
238
197
239
printExtParameters ();
198
240
}
199
241
242
+ void StackchanSystemConfig::printSecretParameters () {
243
+ M5_LOGI (" wifi_ssid: %s" , _secret_config.wifi_info .ssid .c_str ());
244
+ M5_LOGI (" wifi_passws: %s" , _secret_config.wifi_info .password .c_str ());
245
+ M5_LOGI (" apikey_stt: %s" , _secret_config.apikey .stt .c_str ());
246
+ M5_LOGI (" apikey_aiservice: %s" , _secret_config.apikey .aiservice .c_str ());
247
+ M5_LOGI (" apikey_tts: %s" , _secret_config.apikey .tts .c_str ());
248
+ }
200
249
void StackchanSystemConfig::loadExtendConfig (fs::FS& fs, const char * filename, uint32_t yaml_size) { };
201
250
void StackchanSystemConfig::setExtendSettings (DynamicJsonDocument doc) { if ( _extend_config_filename == " " ) return ; };
202
251
void StackchanSystemConfig::printExtParameters (void ) {};
0 commit comments