//-------------------------------------------------------------------------------------------------- void tu_Init ( void ) //-------------------------------------------------------------------------------------------------- { LE_DEBUG("** Initialize Tree User subsystem."); LE_ASSERT(sizeof(uint32_t) >= sizeof(uid_t)); // Startup the internal Legato user API. user_Init(); // Create our memory pools and allocate the info for the root user. UserPoolRef = le_mem_CreatePool(CFG_USER_POOL_NAME, sizeof(User_t)); UserCollectionRef = le_hashmap_Create(CFG_USER_COLLECTION_NAME, 31, le_hashmap_HashUInt32, le_hashmap_EqualsUInt32); le_mem_SetDestructor(UserPoolRef, UserDestructor); // Create our default root user/tree association. CreateUserInfo(0, "root", "system"); }
/** * Initializes all of the device systems. If the clear button * is held down at the end of the initialization then defaults * are restored to all EEPROM settings. * * @return Returns 'OK' if previous data was found by data_Init(), 'ERROR' otherwise. */ status init(void) { Time time; int i; cli(); user_Init(); timer_Wait_MS(1000); // The serial port is now connected to the GSM modem, not the FTDI chip... // coms_Init(); gsm_modem_Init(); usart_Print_Num(SERIAL, UBRR1L); sensor_Init(true); data_Init(); if (user_Get_Button(BUTTON_CLEAR)) { for (i = 0; i < 50; i++) { timer_Wait_MS(50); user_Toggle_LED(LED_CLEAR); user_Toggle_LED(LED_STOP); user_Toggle_LED(LED_START); user_Toggle_LED(LED_POWER); } adx_Calibrate(); rtc_Init(); data_Reset_EEPROM(); wdt_enable(WDTO_120MS); } // Hard-coded time and date for now since we don't have // an application to set the time with... // We should really try to get this from the GSM modem time.hours = 12; // set to noon time.minutes = 0; time.seconds = 0; time.month = 2; // March time.dow = 5; // Thursday time.year = 12; // 2012 time.date = 1; // The 1st rtc_Set_Time(&time); sei(); return OK; }
/** * Initializes all of the device systems. If the clear button * is held down at the end of the initialization then defaults * are restored to all EEPROM settings. * * @return Returns 'OK' if previous data was found by data_Init(), 'ERROR' otherwise. */ status init(void) { int i; cli(); user_Init(); timer_Wait_MS(1000); coms_Init(); sensor_Init(true); data_Init(); if (user_Get_Button(BUTTON_CLEAR)) { for (i = 0; i < 50; i++) { timer_Wait_MS(50); user_Toggle_LED(LED_CLEAR); user_Toggle_LED(LED_STOP); user_Toggle_LED(LED_START); user_Toggle_LED(LED_POWER); } adx_Calibrate(); rtc_Init(); data_Reset_EEPROM(); wdt_enable(WDTO_120MS); } sei(); return OK; }
//-------------------------------------------------------------------------------------------------- static void Load ( void ) //-------------------------------------------------------------------------------------------------- { le_result_t result; // Connect to the Configuration API server. le_cfg_ConnectService(); // Initialize the "User API". user_Init(); // Start a read transaction on the root of the "system" configuration tree. le_cfg_IteratorRef_t i = le_cfg_CreateReadTxn("system:"); // Tell the Service Directory to delete all existing bindings. SendUnbindAllRequest(); // Iterate over the users collection. le_cfg_GoToNode(i, "/users"); result = le_cfg_GoToFirstChild(i); while (result == LE_OK) { uid_t uid; if (GetUserUid(i, &uid) == LE_OK) { // For each user, iterate over the bindings collection, sending the binding to // the Service Directory. le_cfg_GoToNode(i, "bindings"); result = le_cfg_GoToFirstChild(i); while (result == LE_OK) { SendBindRequest(uid, i); result = le_cfg_GoToNextSibling(i); } // Go back up to the user name node. le_cfg_GoToNode(i, "../.."); } // Move on to the next user. result = le_cfg_GoToNextSibling(i); } // Iterate over the apps collection. le_cfg_GoToNode(i, "/apps"); result = le_cfg_GoToFirstChild(i); while (result == LE_OK) { uid_t uid; if (GetAppUid(i, &uid) == LE_OK) { // For each app, iterate over the bindings collection, sending the binding to // the Service Directory. le_cfg_GoToNode(i, "bindings"); result = le_cfg_GoToFirstChild(i); while (result == LE_OK) { SendBindRequest(uid, i); result = le_cfg_GoToNextSibling(i); } // Go back up to the app's node. le_cfg_GoToNode(i, "../.."); } // Move on to the next app. result = le_cfg_GoToNextSibling(i); } exit(EXIT_SUCCESS); }