static void InitMandatoryPropertiesInRAM() { char* machineIdValue = propertyStoreRuntimeValues[AJSVC_PROPERTY_STORE_APP_ID].value[AJSVC_PROPERTY_STORE_NO_LANGUAGE_INDEX]; const char* currentAppIdValue = AJSVC_PropertyStore_GetValue(AJSVC_PROPERTY_STORE_APP_ID); const char* currentDeviceIdValue = AJSVC_PropertyStore_GetValue(AJSVC_PROPERTY_STORE_DEVICE_ID); const char* currentDeviceNameValue = AJSVC_PropertyStore_GetValue(AJSVC_PROPERTY_STORE_DEVICE_NAME); size_t serialIdLen = 0; size_t machineIdLen = 0; AJ_GUID theAJ_GUID; AJ_Status status; char deviceName[DEVICE_NAME_VALUE_LENGTH + 1] = { 0 }; if (currentAppIdValue == NULL || currentAppIdValue[0] == '\0') { status = AJ_GetLocalGUID(&theAJ_GUID); if (status == AJ_OK) { AJ_GUID_ToString(&theAJ_GUID, machineIdValue, propertyStoreRuntimeValues[AJSVC_PROPERTY_STORE_APP_ID].size); } } if (currentDeviceIdValue == NULL || currentDeviceIdValue[0] == '\0') { AJSVC_PropertyStore_SetValue(AJSVC_PROPERTY_STORE_DEVICE_ID, machineIdValue); } if (currentDeviceNameValue == NULL || currentDeviceNameValue[0] == '\0') { #ifdef ONBOARDING_SERVICE serialIdLen = AJOBS_DEVICE_SERIAL_ID_LEN; #else serialIdLen = 7; #endif machineIdLen = strlen(machineIdValue); #ifdef _WIN32 _snprintf(deviceName, DEVICE_NAME_VALUE_LENGTH + 1, "%s %s %s", deviceManufactureName, deviceProductName, &machineIdValue[machineIdLen - min(serialIdLen, machineIdLen)]); #else snprintf(deviceName, DEVICE_NAME_VALUE_LENGTH + 1, "%s %s %s", deviceManufactureName, deviceProductName, &machineIdValue[machineIdLen - min(serialIdLen, machineIdLen)]); #endif AJSVC_PropertyStore_SetValue(AJSVC_PROPERTY_STORE_DEVICE_NAME, deviceName); } }
static AJ_Status SetPasscode(const char* daemonRealm, const uint8_t* newPasscode, uint8_t newPasscodeLen) { AJ_Status status = AJ_OK; char newStringPasscode[PASSWORD_VALUE_LENGTH + 1]; status = AJ_RawToHex(newPasscode, newPasscodeLen, newStringPasscode, sizeof(newStringPasscode), FALSE); if (status != AJ_OK) { return status; } if (AJSVC_PropertyStore_SetValue(AJSVC_PROPERTY_STORE_REALM_NAME, daemonRealm) && AJSVC_PropertyStore_SetValue(AJSVC_PROPERTY_STORE_PASSCODE, newStringPasscode)) { status = AJSVC_PropertyStore_SaveAll(); if (status != AJ_OK) { return status; } AJ_ClearCredentials(); status = AJ_ERR_READ; //Force disconnect of AJ and services to refresh current sessions } else { status = AJSVC_PropertyStore_LoadAll(); if (status != AJ_OK) { return status; } } return status; }