esp_app_main.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. /*
  2. * Squeezelite for esp32
  3. *
  4. * (c) Sebastien 2019
  5. * Philippe G. 2019, philippe_44@outlook.com
  6. *
  7. * This software is released under the MIT License.
  8. * https://opensource.org/licenses/MIT
  9. *
  10. */
  11. #include "platform_esp32.h"
  12. #include "led.h"
  13. #include <stdio.h>
  14. #include <string.h>
  15. #include "freertos/FreeRTOS.h"
  16. #include "driver/gpio.h"
  17. #include "driver/spi_master.h"
  18. #include "freertos/task.h"
  19. #include "esp_system.h"
  20. #include "esp_spi_flash.h"
  21. #include "esp_wifi.h"
  22. #include <esp_event.h>
  23. #include "nvs_flash.h"
  24. #include "esp_log.h"
  25. #include "freertos/event_groups.h"
  26. #include "mdns.h"
  27. #include "lwip/api.h"
  28. #include "lwip/err.h"
  29. #include "lwip/netdb.h"
  30. #include "nvs_utilities.h"
  31. #include "trace.h"
  32. #include "network_manager.h"
  33. #include "squeezelite-ota.h"
  34. #include <math.h>
  35. #include "audio_controls.h"
  36. #include "platform_config.h"
  37. #include "telnet.h"
  38. #include "messaging.h"
  39. #include "gds.h"
  40. #include "gds_default_if.h"
  41. #include "gds_draw.h"
  42. #include "gds_text.h"
  43. #include "gds_font.h"
  44. #include "led_vu.h"
  45. #include "display.h"
  46. #include "accessors.h"
  47. #include "cmd_system.h"
  48. #include "tools.h"
  49. #if defined(CONFIG_WITH_METRICS)
  50. #include "Metrics.h"
  51. #endif
  52. const char unknown_string_placeholder[] = "unknown";
  53. const char null_string_placeholder[] = "null";
  54. EventGroupHandle_t network_event_group;
  55. bool bypass_network_manager=false;
  56. const int CONNECTED_BIT = BIT0;
  57. #define JOIN_TIMEOUT_MS (10000)
  58. #define LOCAL_MAC_SIZE 20
  59. static const char TAG[] = "esp_app_main";
  60. #define DEFAULT_HOST_NAME "squeezelite"
  61. char * fwurl = NULL;
  62. RTC_NOINIT_ATTR uint32_t RebootCounter ;
  63. RTC_NOINIT_ATTR uint32_t RecoveryRebootCounter ;
  64. RTC_NOINIT_ATTR uint16_t ColdBootIndicatorFlag;
  65. bool cold_boot=true;
  66. #ifdef CONFIG_IDF_TARGET_ESP32S3
  67. extern const char _ctype_[];
  68. const char* __ctype_ptr__ = _ctype_;
  69. #endif
  70. typedef struct {
  71. const char *key;
  72. const char *value;
  73. } DefaultStringVal;
  74. typedef struct {
  75. const char *key;
  76. unsigned int uint_value;
  77. bool is_signed;
  78. } DefaultNumVal;
  79. const DefaultNumVal defaultNumVals[] = {
  80. {"ota_erase_blk", OTA_FLASH_ERASE_BLOCK, 0},
  81. {"ota_stack", OTA_STACK_SIZE, 0},
  82. {"ota_prio", OTA_TASK_PRIOTITY, 1}
  83. };
  84. const DefaultStringVal defaultStringVals[] = {
  85. {"equalizer", ""},
  86. {"loudness", "0"},
  87. {"actrls_config", ""},
  88. {"lms_ctrls_raw", "n"},
  89. {"rotary_config", CONFIG_ROTARY_ENCODER},
  90. {"display_config", CONFIG_DISPLAY_CONFIG},
  91. {"eth_config", CONFIG_ETH_CONFIG},
  92. {"i2c_config", CONFIG_I2C_CONFIG},
  93. {"spi_config", CONFIG_SPI_CONFIG},
  94. {"set_GPIO", CONFIG_SET_GPIO},
  95. {"sleep_config", ""},
  96. {"led_brightness", ""},
  97. {"spdif_config", ""},
  98. {"dac_config", ""},
  99. {"dac_controlset", ""},
  100. {"jack_mutes_amp", "n"},
  101. {"gpio_exp_config", CONFIG_GPIO_EXP_CONFIG},
  102. {"bat_config", ""},
  103. {"metadata_config", ""},
  104. {"telnet_enable", ""},
  105. {"telnet_buffer", "40000"},
  106. {"telnet_block", "500"},
  107. {"stats", "n"},
  108. {"rel_api", CONFIG_RELEASE_API},
  109. {"pollmx", "600"},
  110. {"pollmin", "15"},
  111. {"ethtmout", "8"},
  112. {"dhcp_tmout", "8"},
  113. {"target", CONFIG_TARGET},
  114. {"led_vu_config", ""},
  115. #ifdef CONFIG_BT_SINK
  116. {"bt_sink_pin", STR(CONFIG_BT_SINK_PIN)},
  117. {"bt_sink_volume", "127"},
  118. // Note: register_default_with_mac("bt_name", CONFIG_BT_NAME); is a special case
  119. {"enable_bt_sink", STR(CONFIG_BT_SINK)},
  120. {"a2dp_dev_name", CONFIG_A2DP_DEV_NAME},
  121. {"a2dp_ctmt", STR(CONFIG_A2DP_CONNECT_TIMEOUT_MS)},
  122. {"a2dp_ctrld", STR(CONFIG_A2DP_CONTROL_DELAY_MS)},
  123. {"a2dp_sink_name", CONFIG_A2DP_SINK_NAME},
  124. {"autoexec", "1"},
  125. #ifdef CONFIG_AIRPLAY_SINK
  126. {"airplay_port", CONFIG_AIRPLAY_PORT},
  127. {"enable_airplay", STR(CONFIG_AIRPLAY_SINK)}
  128. #endif
  129. #endif
  130. };
  131. static bool bNetworkConnected=false;
  132. // as an exception _init function don't need include
  133. extern void services_init(void);
  134. extern void services_sleep_init(void);
  135. extern void display_init(char *welcome);
  136. extern void led_vu_init(void);
  137. extern void target_init(char *target);
  138. const char * str_or_unknown(const char * str) { return (str?str:unknown_string_placeholder); }
  139. const char * str_or_null(const char * str) { return (str?str:null_string_placeholder); }
  140. bool is_recovery_running;
  141. bool is_network_connected(){
  142. return bNetworkConnected;
  143. }
  144. void cb_connection_got_ip(nm_state_t new_state, int sub_state){
  145. const char *hostname;
  146. static ip4_addr_t ip;
  147. tcpip_adapter_ip_info_t ipInfo;
  148. network_get_ip_info(&ipInfo);
  149. if (ip.addr && ipInfo.ip.addr != ip.addr) {
  150. ESP_LOGW(TAG, "IP change, need to reboot");
  151. if(!wait_for_commit()){
  152. ESP_LOGW(TAG,"Unable to commit configuration. ");
  153. }
  154. esp_restart();
  155. }
  156. // initializing mDNS
  157. network_get_hostname(&hostname);
  158. mdns_init();
  159. mdns_hostname_set(hostname);
  160. ESP_LOGI(TAG, "Network connected and mDNS initialized with %s", hostname);
  161. messaging_post_message(MESSAGING_INFO,MESSAGING_CLASS_SYSTEM,"Network connected");
  162. xEventGroupSetBits(network_event_group, CONNECTED_BIT);
  163. bNetworkConnected=true;
  164. led_unpush(LED_GREEN);
  165. if(is_recovery_running){
  166. // when running in recovery, send a LMS discovery message
  167. // to find a running instance. This is to enable using
  168. // the plugin's proxy mode for FW download and avoid
  169. // expired certificate issues.
  170. discover_ota_server(5);
  171. }
  172. }
  173. void cb_connection_sta_disconnected(nm_state_t new_state, int sub_state){
  174. led_blink_pushed(LED_GREEN, 250, 250);
  175. messaging_post_message(MESSAGING_WARNING,MESSAGING_CLASS_SYSTEM,"Wifi disconnected");
  176. bNetworkConnected=false;
  177. xEventGroupClearBits(network_event_group, CONNECTED_BIT);
  178. }
  179. bool wait_for_wifi(){
  180. bool connected=(xEventGroupGetBits(network_event_group) & CONNECTED_BIT)!=0;
  181. if(!connected){
  182. ESP_LOGD(TAG,"Waiting for Network...");
  183. connected = (xEventGroupWaitBits(network_event_group, CONNECTED_BIT,
  184. pdFALSE, pdTRUE, JOIN_TIMEOUT_MS / portTICK_PERIOD_MS)& CONNECTED_BIT)!=0;
  185. if(!connected){
  186. ESP_LOGW(TAG,"Network timeout.");
  187. }
  188. else
  189. {
  190. ESP_LOGI(TAG,"Network Connected!");
  191. }
  192. }
  193. return connected;
  194. }
  195. char * process_ota_url(){
  196. ESP_LOGI(TAG,"Checking for update url");
  197. char * fwurl=config_alloc_get(NVS_TYPE_STR, "fwurl");
  198. if(fwurl!=NULL)
  199. {
  200. ESP_LOGD(TAG,"Deleting nvs entry for Firmware URL %s", fwurl);
  201. config_delete_key("fwurl");
  202. }
  203. return fwurl;
  204. }
  205. esp_log_level_t get_log_level_from_char(char * level){
  206. if(!strcasecmp(level, "NONE" )) { return ESP_LOG_NONE ;}
  207. if(!strcasecmp(level, "ERROR" )) { return ESP_LOG_ERROR ;}
  208. if(!strcasecmp(level, "WARN" )) { return ESP_LOG_WARN ;}
  209. if(!strcasecmp(level, "INFO" )) { return ESP_LOG_INFO ;}
  210. if(!strcasecmp(level, "DEBUG" )) { return ESP_LOG_DEBUG ;}
  211. if(!strcasecmp(level, "VERBOSE" )) { return ESP_LOG_VERBOSE;}
  212. return ESP_LOG_WARN;
  213. }
  214. void set_log_level(char * tag, char * level){
  215. esp_log_level_set(tag, get_log_level_from_char(level));
  216. }
  217. #define DEFAULT_NAME_WITH_MAC(var,defval) char var[strlen(defval)+sizeof(macStr)]; strcpy(var,defval); strcat(var,macStr)
  218. void register_default_string_val(const char * key, const char * value){
  219. char * existing =(char *)config_alloc_get(NVS_TYPE_STR,key );
  220. ESP_LOGD(TAG,"Register default called with: %s= %s",key,value );
  221. if(!existing) {
  222. ESP_LOGI(TAG,"Registering default value for key %s, value %s", key, value );
  223. config_set_default(NVS_TYPE_STR, key, value, 0);
  224. }
  225. else {
  226. ESP_LOGD(TAG,"Value found for %s: %s",key,existing );
  227. }
  228. FREE_AND_NULL(existing);
  229. }
  230. void register_single_default_num_val(const DefaultNumVal *entry) {
  231. char number_buffer[101] = {};
  232. if (entry->is_signed) {
  233. snprintf(number_buffer, sizeof(number_buffer) - 1, "%d", entry->uint_value);
  234. } else {
  235. snprintf(number_buffer, sizeof(number_buffer) - 1, "%u", entry->uint_value);
  236. }
  237. register_default_string_val(entry->key, number_buffer);
  238. }
  239. char * alloc_get_string_with_mac(const char * val) {
  240. uint8_t mac[6];
  241. char macStr[LOCAL_MAC_SIZE + 1];
  242. char* fullvalue = NULL;
  243. esp_read_mac((uint8_t*)&mac, ESP_MAC_WIFI_STA);
  244. snprintf(macStr, LOCAL_MAC_SIZE - 1, "-%x%x%x", mac[3], mac[4], mac[5]);
  245. fullvalue = malloc_init_external(strlen(val)+sizeof(macStr)+1);
  246. if(fullvalue){
  247. strcpy(fullvalue, val);
  248. strcat(fullvalue, macStr);
  249. }
  250. else {
  251. ESP_LOGE(TAG,"malloc failed for value %s", val);
  252. }
  253. return fullvalue;
  254. }
  255. void register_default_with_mac(const char* key, char* defval) {
  256. char * fullvalue=alloc_get_string_with_mac(defval);
  257. if(fullvalue){
  258. register_default_string_val(key,fullvalue);
  259. FREE_AND_NULL(fullvalue);
  260. }
  261. else {
  262. ESP_LOGE(TAG,"malloc failed for value %s", key);
  263. }
  264. }
  265. void register_default_nvs(){
  266. #ifdef CONFIG_CSPOT_SINK
  267. register_default_string_val("enable_cspot", STR(CONFIG_CSPOT_SINK));
  268. cJSON * cspot_config=config_alloc_get_cjson("cspot_config");
  269. if(!cspot_config){
  270. char * name = alloc_get_string_with_mac(DEFAULT_HOST_NAME);
  271. if(name){
  272. cjson_update_string(&cspot_config,"deviceName",name);
  273. cjson_update_number(&cspot_config,"bitrate",160);
  274. // the call below saves the config and frees the json pointer
  275. config_set_cjson_str_and_free("cspot_config",cspot_config);
  276. FREE_AND_NULL(name);
  277. }
  278. else {
  279. register_default_string_val("cspot_config", "");
  280. }
  281. }
  282. #endif
  283. #ifdef CONFIG_AIRPLAY_SINK
  284. register_default_with_mac("airplay_name", CONFIG_AIRPLAY_NAME);
  285. #endif
  286. #ifdef CONFIG_BT_SINK
  287. register_default_with_mac("bt_name", CONFIG_BT_NAME);
  288. #endif
  289. register_default_with_mac("host_name", DEFAULT_HOST_NAME);
  290. register_default_with_mac("ap_ssid", CONFIG_DEFAULT_AP_SSID);
  291. register_default_with_mac("autoexec1",CONFIG_DEFAULT_COMMAND_LINE " -n " DEFAULT_HOST_NAME);
  292. for (int i = 0; i < sizeof(defaultStringVals) / sizeof(DefaultStringVal); ++i) {
  293. register_default_string_val(defaultStringVals[i].key, defaultStringVals[i].value);
  294. }
  295. for (int i = 0; i < sizeof(defaultNumVals) / sizeof(DefaultNumVal); ++i) {
  296. register_single_default_num_val(&defaultNumVals[i]);
  297. }
  298. wait_for_commit();
  299. ESP_LOGD(TAG,"Done setting default values in nvs.");
  300. }
  301. uint32_t halSTORAGE_RebootCounterRead(void) { return RebootCounter ; }
  302. uint32_t halSTORAGE_RebootCounterUpdate(int32_t xValue) {
  303. if(RebootCounter >100) {
  304. RebootCounter = 0;
  305. RecoveryRebootCounter = 0;
  306. }
  307. RebootCounter = (xValue != 0) ? (RebootCounter + xValue) : 0;
  308. RecoveryRebootCounter = (xValue != 0) && is_recovery_running ? (RecoveryRebootCounter + xValue) : 0;
  309. return RebootCounter ;
  310. }
  311. void handle_ap_connect(nm_state_t new_state, int sub_state){
  312. start_telnet(NULL);
  313. }
  314. void handle_network_up(nm_state_t new_state, int sub_state){
  315. halSTORAGE_RebootCounterUpdate(0);
  316. }
  317. esp_reset_reason_t xReason=ESP_RST_UNKNOWN;
  318. void app_main()
  319. {
  320. if(ColdBootIndicatorFlag != 0xFACE ){
  321. ESP_LOGI(TAG, "System is booting from power on.");
  322. cold_boot = true;
  323. ColdBootIndicatorFlag = 0xFACE;
  324. }
  325. else {
  326. cold_boot = false;
  327. }
  328. const esp_partition_t *running = esp_ota_get_running_partition();
  329. is_recovery_running = (running->subtype == ESP_PARTITION_SUBTYPE_APP_FACTORY);
  330. xReason = esp_reset_reason();
  331. ESP_LOGI(TAG,"Reset reason is: %u", xReason);
  332. if(!is_recovery_running ) {
  333. /* unscheduled restart (HW, Watchdog or similar) thus increment dynamic
  334. * counter then log current boot statistics as a warning */
  335. uint32_t Counter = halSTORAGE_RebootCounterUpdate(1) ; // increment counter
  336. ESP_LOGI(TAG,"Reboot counter=%u\n", Counter) ;
  337. if (Counter == 5) {
  338. guided_factory();
  339. }
  340. }
  341. else {
  342. uint32_t Counter = halSTORAGE_RebootCounterUpdate(1) ; // increment counter
  343. if(RecoveryRebootCounter==1 && Counter>=5){
  344. // First time we are rebooting in recovery after crashing
  345. messaging_post_message(MESSAGING_ERROR,MESSAGING_CLASS_SYSTEM,"System was forced into recovery mode after crash likely caused by some bad configuration\n");
  346. }
  347. ESP_LOGI(TAG,"Recovery Reboot counter=%u\n", Counter) ;
  348. if (RecoveryRebootCounter == 5) {
  349. ESP_LOGW(TAG,"System rebooted too many times. This could be an indication that configuration is corrupted. Erasing config.");
  350. erase_settings_partition();
  351. // reboot one more time
  352. guided_factory();
  353. }
  354. if (RecoveryRebootCounter >5){
  355. messaging_post_message(MESSAGING_ERROR,MESSAGING_CLASS_SYSTEM,"System was forced into recovery mode after crash likely caused by some bad configuration. Configuration was reset to factory.\n");
  356. }
  357. }
  358. char * fwurl = NULL;
  359. MEMTRACE_PRINT_DELTA();
  360. ESP_LOGI(TAG,"Starting app_main");
  361. initialize_nvs();
  362. MEMTRACE_PRINT_DELTA();
  363. #if defined(CONFIG_WITH_METRICS)
  364. ESP_LOGI(TAG,"Setting up metrics.");
  365. metrics_init();
  366. MEMTRACE_PRINT_DELTA();
  367. #endif
  368. ESP_LOGI(TAG,"Setting up telnet.");
  369. init_telnet(); // align on 32 bits boundaries
  370. MEMTRACE_PRINT_DELTA();
  371. ESP_LOGI(TAG,"Setting up config subsystem.");
  372. config_init();
  373. MEMTRACE_PRINT_DELTA();
  374. ESP_LOGD(TAG,"Creating event group for wifi");
  375. network_event_group = xEventGroupCreate();
  376. ESP_LOGD(TAG,"Clearing CONNECTED_BIT from wifi group");
  377. xEventGroupClearBits(network_event_group, CONNECTED_BIT);
  378. ESP_LOGI(TAG,"Registering default values");
  379. register_default_nvs();
  380. MEMTRACE_PRINT_DELTA();
  381. ESP_LOGI(TAG,"Configuring services");
  382. services_init();
  383. MEMTRACE_PRINT_DELTA();
  384. ESP_LOGI(TAG,"Initializing display");
  385. display_init("SqueezeESP32");
  386. MEMTRACE_PRINT_DELTA();
  387. char *target = config_alloc_get_str("target", CONFIG_TARGET, NULL);
  388. if (target) {
  389. target_init(target);
  390. free(target);
  391. }
  392. ESP_LOGI(TAG,"Initializing led_vu");
  393. led_vu_init();
  394. if(is_recovery_running) {
  395. if (display) {
  396. GDS_ClearExt(display, true);
  397. GDS_SetFont(display, &Font_line_2 );
  398. GDS_TextPos(display, GDS_FONT_DEFAULT, GDS_TEXT_CENTERED, GDS_TEXT_CLEAR | GDS_TEXT_UPDATE, "RECOVERY");
  399. }
  400. if(led_display) {
  401. led_vu_color_yellow(LED_VU_BRIGHT);
  402. }
  403. }
  404. #if defined(CONFIG_WITH_METRICS)
  405. metrics_event_boot(is_recovery_running?"recovery":"ota");
  406. #endif
  407. ESP_LOGD(TAG,"Getting firmware OTA URL (if any)");
  408. fwurl = process_ota_url();
  409. ESP_LOGD(TAG,"Getting value for WM bypass, nvs 'bypass_wm'");
  410. char * bypass_wm = config_alloc_get_default(NVS_TYPE_STR, "bypass_wm", "0", 0);
  411. if(bypass_wm==NULL)
  412. {
  413. ESP_LOGE(TAG, "Unable to retrieve the Wifi Manager bypass flag");
  414. bypass_network_manager = false;
  415. }
  416. else {
  417. bypass_network_manager=(strcmp(bypass_wm,"1")==0 ||strcasecmp(bypass_wm,"y")==0);
  418. }
  419. if(!is_recovery_running){
  420. ESP_LOGD(TAG,"Getting audio control mapping ");
  421. char *actrls_config = config_alloc_get_default(NVS_TYPE_STR, "actrls_config", "", 0);
  422. if (actrls_init(actrls_config) == ESP_OK) {
  423. ESP_LOGD(TAG,"Initializing audio control buttons type %s", actrls_config);
  424. } else {
  425. ESP_LOGD(TAG,"No audio control buttons");
  426. }
  427. if (actrls_config) free(actrls_config);
  428. }
  429. /* start the wifi manager */
  430. ESP_LOGD(TAG,"Blinking led");
  431. led_blink_pushed(LED_GREEN, 250, 250);
  432. MEMTRACE_PRINT_DELTA();
  433. if(bypass_network_manager){
  434. ESP_LOGW(TAG,"Network manager is disabled. Use command line for wifi control.");
  435. }
  436. else {
  437. ESP_LOGI(TAG,"Starting Network Manager");
  438. network_start();
  439. MEMTRACE_PRINT_DELTA();
  440. network_register_state_callback(NETWORK_WIFI_ACTIVE_STATE,WIFI_CONNECTED_STATE, "cb_connection_got_ip", &cb_connection_got_ip);
  441. network_register_state_callback(NETWORK_ETH_ACTIVE_STATE,ETH_ACTIVE_CONNECTED_STATE, "cb_connection_got_ip",&cb_connection_got_ip);
  442. network_register_state_callback(NETWORK_WIFI_ACTIVE_STATE,WIFI_LOST_CONNECTION_STATE, "cb_connection_sta_disconnected",&cb_connection_sta_disconnected);
  443. /* Start the telnet service after we are certain that the network stack has been properly initialized.
  444. * This can be either after we're started the AP mode, or after we've started the STA mode */
  445. network_register_state_callback(NETWORK_INITIALIZING_STATE,-1, "handle_ap_connect", &handle_ap_connect);
  446. network_register_state_callback(NETWORK_ETH_ACTIVE_STATE,ETH_ACTIVE_LINKDOWN_STATE, "handle_network_up", &handle_network_up);
  447. network_register_state_callback(NETWORK_WIFI_ACTIVE_STATE,WIFI_INITIALIZING_STATE, "handle_network_up", &handle_network_up);
  448. MEMTRACE_PRINT_DELTA();
  449. }
  450. MEMTRACE_PRINT_DELTA_MESSAGE("Starting Console");
  451. console_start();
  452. MEMTRACE_PRINT_DELTA_MESSAGE("Console started");
  453. if(fwurl && strlen(fwurl)>0){
  454. if(is_recovery_running){
  455. while(!bNetworkConnected){
  456. wait_for_wifi();
  457. taskYIELD();
  458. }
  459. ESP_LOGI(TAG,"Updating firmware from link: %s",fwurl);
  460. #if defined(CONFIG_WITH_METRICS)
  461. metrics_event("fw_update");
  462. #endif
  463. start_ota(fwurl, NULL, 0);
  464. }
  465. else {
  466. ESP_LOGE(TAG,"Restarted to application partition. We're not going to perform OTA!");
  467. }
  468. free(fwurl);
  469. }
  470. services_sleep_init();
  471. messaging_post_message(MESSAGING_INFO,MESSAGING_CLASS_SYSTEM,"System started");
  472. }