public void GetFirmware(HttpContext context, string controllerId)
        {
            int id = ApiBase.ParseId(controllerId);
            ControllerFirmware firmware = _controllerHandler.GetFirmware(id);
            string             json     = JsonSerializer.SerializeJson(firmware);

            context.Response.Payload.Write(json);
            context.Response.Status = HttpStatus.OK;
        }
Beispiel #2
0
        /// <summary>
        /// Returns an instance of <see cref="ControllerFirmware"/> encompassing all firmware details of the controller having the passed <see cref="Controller.Id"/>.
        /// The method throws an <see cref="ResourceNotFoundException"/> if the specified <see cref="Controller"/> does not exists.
        /// </summary>
        /// <param name="id"><see cref="Controller.Id"/> of the controller</param>
        /// <returns>instance of <see cref="ControllerFirmware"/></returns>
        public ControllerFirmware GetFirmware(int id)
        {
            if (_controllerStorage.HasControllerById(id))
            {
                IControllerDataSet cds      = _controllerStorage.GetControllerById(id);
                ControllerFirmware firmware = new ControllerFirmware(id, cds.UuId, cds.LedCount);
                firmware.DeviceName   = cds.DeviceName;
                firmware.FirmwareId   = cds.FirmwareId;
                firmware.MajorVersion = cds.MajorVersion;
                firmware.MinorVersion = cds.MinorVersion;
                firmware.TimeStamp    = cds.Timestamp;

                return(firmware);
            }
            else
            {
                throw new ResourceNotFoundException(ResourceNotFoundException.MSG_CONTROLLER_NOT_FOUND.Replace("{VALUE}", id + ""));
            }
        }