/// <summary> /// Reads the device's credentials from the local filesystem /// </summary> /// <param name="serialNumber">the device's serial number</param> /// <returns>Credentials object. Null in case of an exception</returns> public RegisterDeviceResponse ReadCreds(string serialNumber) { try { return(JsonConvert.DeserializeObject <RegisterDeviceResponse>( FileMethods.ReadJsonFromFile(CredFileName(serialNumber)))); } catch (Exception) { return(null); } }
/// <summary> /// Reads the device's configurations file from the local file system and retunrs its string representation /// </summary> /// <param name="deviceUuid">The Universal Unique ID of the device</param> /// <returns>the configurations JSON as a string.</returns> public string ReadConfig(string deviceUuid) { return(FileMethods.ReadJsonFromFile(ConfigFileName(deviceUuid))); }
/// <summary> /// Save the device's configurations to the local file system /// </summary> /// <param name="deviceUuid">The Universal Unique ID of the device</param> /// <param name="obj">The configuraion object</param> public void SaveConfig(string deviceUuid, object obj) { FileMethods.WriteJsonToFile(ConfigFileName(deviceUuid), obj); }
/// <summary> /// Saves the credentials of the device to the local file system /// </summary> /// <param name="serialNumber">The device's serial number</param> /// <param name="cred">Credentials object</param> public void SaveCreds(string serialNumber, RegisterDeviceResponse cred) { FileMethods.WriteJsonToFile(CredFileName(serialNumber), cred); }