예제 #1
0
        private bool VerifyEui(EmberEui64 eui)
        {
            bool result = false;

            using (var manufacturingStoreRepository = dataContextFactory.CreateManufacturingStoreRepository())
            {
                var euiString = eui.ToString();
                var dbEui     = manufacturingStoreRepository.EuiLists.AsNoTracking().FirstOrDefault(e => e.EUI == euiString);

                string dbEuiSKU = null;
                if (dbEui != null)
                {
                    dbEuiSKU = dbEui.TargetDevices.OrderByDescending(x => x.Id).FirstOrDefault()?.TestSession?.Product?.SKU;

                    if (dbEuiSKU == ValidProduct?.SKU)
                    {
                        result = true;
                    }
                    else
                    {
                        errorProducerService.AddMessage(new ErrorMessage(string.Format("SKU: {0} is invalid for the selected product", dbEuiSKU), ErrorType.Error));
                    }
                }
                else
                {
                    if (ValidProduct?.Board.ChipType.Name == EM250_CHIP)
                    {
                        // EM250 Chips do not have EUIs in DB since they are not coded in EBL
                        dbEui = new EuiList()
                        {
                            EUI = euiString,
                            ProductionSiteId = CurrentStationSite.ProductionSite.Id
                        };

                        manufacturingStoreRepository.EuiLists.Add(dbEui);
                        manufacturingStoreRepository.SaveChanges();

                        result = true;
                    }
                    else
                    {
                        errorProducerService.AddMessage(new ErrorMessage(string.Format("EUI: {0} could not be found in database", euiString), ErrorType.Error));
                    }
                }

                return(result);
            }
        }
예제 #2
0
        public bool ConfigureEzsp()
        {
            bool result = true;

            var policyResponse = Ezsp.SetPolicy(EzspPolicyId.EZSP_UNICAST_REPLIES_POLICY, EzspDecisionId.EZSP_HOST_WILL_NOT_SUPPLY_REPLY);

            result &= (policyResponse?.Status == EmberStatus.EMBER_SUCCESS);

            var configs = new List <EzspSetConfigurationValue>();

            configs.Add(new EzspSetConfigurationValue(EzspConfigId.EZSP_CONFIG_STACK_PROFILE, 2));
            configs.Add(new EzspSetConfigurationValue(EzspConfigId.EZSP_CONFIG_PAN_ID_CONFLICT_REPORT_THRESHOLD, 10));
            configs.Add(new EzspSetConfigurationValue(EzspConfigId.EZSP_CONFIG_SOURCE_ROUTE_TABLE_SIZE, 10));
            configs.Add(new EzspSetConfigurationValue(EzspConfigId.EZSP_CONFIG_TX_POWER_MODE, 0));
            configs.Add(new EzspSetConfigurationValue(EzspConfigId.EZSP_CONFIG_MAX_END_DEVICE_CHILDREN, 20));
            configs.Add(new EzspSetConfigurationValue(EzspConfigId.EZSP_CONFIG_INDIRECT_TRANSMISSION_TIMEOUT, 8 * 1000));
            configs.Add(new EzspSetConfigurationValue(EzspConfigId.EZSP_CONFIG_ADDRESS_TABLE_SIZE, 20));
            configs.Add(new EzspSetConfigurationValue(EzspConfigId.EZSP_CONFIG_APS_UNICAST_MESSAGE_COUNT, 10));

            foreach (var config in configs)
            {
                var res = Ezsp.SetConfigurationValue(config.ConfigId, config.Value);

                result &= (res?.Status == EzspStatus.EZSP_SUCCESS);
            }

            var endpointResponse = Ezsp.AddEndpoint(1, ZclConstants.HomeAutomationProfileId, 1, 0, new ushort[] { ZCL.ClusterIds.OtaUpgradeCluster }, new ushort[] { ZCL.ClusterIds.IasZone }) ?? new EmberStatusResponse(EmberStatus.EMBER_ERR_FATAL);

            result &= (endpointResponse?.Status == EmberStatus.EMBER_SUCCESS);

            if (!result)
            {
                errorProducerService.AddMessage(new ErrorMessage("Unable to configure USB Stick", ErrorType.Error));
            }

            return(result);
        }
예제 #3
0
        public void SaveOtaUpgrade(int ProductId, int FirmwareId, string Eui)
        {
            if (UserSession == null)
            {
                errorProducerService.AddMessage(new ErrorMessage("No User Session Open", ErrorType.Exception));
            }

            using (var manufacturingStoreRepository = dataContextFactory.CreateManufacturingStoreRepository())
            {
                var product = manufacturingStoreRepository.Products.AsNoTracking().FirstOrDefault(prod => prod.Id == ProductId);

                if (product == null)
                {
                    errorProducerService.AddMessage(new ErrorMessage(string.Format("No Product found with Id {0}", ProductId), ErrorType.Exception));
                    return;
                }

                var boardRevision = product.Board.BoardRevisions.OrderByDescending(br => br.Revision).FirstOrDefault();

                if (boardRevision == null)
                {
                    errorProducerService.AddMessage(new ErrorMessage(string.Format("No Board Revisions found for Product Id {0}", ProductId), ErrorType.Exception));
                    return;
                }

                var result = manufacturingStoreRepository.Results.AsNoTracking().FirstOrDefault(res => res.Text == RESULT_PASSED);

                if (result == null)
                {
                    errorProducerService.AddMessage(new ErrorMessage("Passed Result not found, something is misconfigured", ErrorType.Exception));
                }

                // Create Test Session
                var testSession = new TestSession();
                testSession.ProductId       = ProductId;
                testSession.BoardRevisionId = boardRevision.Id;
                testSession.FirmwareId      = FirmwareId;
                testSession.UserSessionId   = UserSession.Id;
                testSession.ResultId        = result.Id;
                testSession.StartTime       = DateTime.Now;
                manufacturingStoreRepository.TestSessions.Add(testSession);
                manufacturingStoreRepository.SaveChanges();

                var euiList = manufacturingStoreRepository.EuiLists.AsNoTracking().FirstOrDefault(eui => eui.EUI == Eui);

                if (euiList == null)
                {
                    errorProducerService.AddMessage(new ErrorMessage(string.Format("EUI {0} not found in database for OTAed device", Eui), ErrorType.Exception));
                }

                var isa = manufacturingStoreRepository.InsightAdapters.AsNoTracking().FirstOrDefault(insight => insight.Name == OTA_ISA_NAME);

                if (isa == null)
                {
                    errorProducerService.AddMessage(new ErrorMessage("OTA Spoof ISA not found. Something is misconfigured", ErrorType.Exception));
                }

                // Create Target Device
                var targetDevice = new TargetDevice();
                targetDevice.IsaId         = isa.Id;
                targetDevice.EuiId         = euiList.Id;
                targetDevice.TestSessionId = testSession.Id;
                targetDevice.ResultId      = result.Id;
                manufacturingStoreRepository.TargetDevices.Add(targetDevice);

                testSession.EndTime = DateTime.Now;

                manufacturingStoreRepository.SaveChanges();
            }
        }