Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020-present Open Networking Foundation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 17 | //Package adaptercoreonu provides the utility for onu devices, flows and statistics |
| 18 | package adaptercoreonu |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 19 | |
| 20 | import ( |
| 21 | "context" |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 22 | "errors" |
Holger Hildebrandt | 2ff21f1 | 2020-08-13 14:38:02 +0000 | [diff] [blame] | 23 | "time" |
| 24 | |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 25 | "github.com/opencord/omci-lib-go" |
| 26 | me "github.com/opencord/omci-lib-go/generated" |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 27 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 28 | //"sync" |
| 29 | //"time" |
| 30 | |
| 31 | "github.com/looplab/fsm" |
| 32 | "github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif" |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 33 | "github.com/opencord/voltha-lib-go/v3/pkg/db" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 34 | |
| 35 | //"github.com/opencord/voltha-lib-go/v3/pkg/kafka" |
| 36 | "github.com/opencord/voltha-lib-go/v3/pkg/log" |
| 37 | //ic "github.com/opencord/voltha-protos/v3/go/inter_container" |
| 38 | //"github.com/opencord/voltha-protos/v3/go/openflow_13" |
| 39 | //"github.com/opencord/voltha-protos/v3/go/voltha" |
| 40 | ) |
| 41 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 42 | const ( |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 43 | // events of MibUpload FSM |
| 44 | ulEvStart = "ulEvStart" |
| 45 | ulEvResetMib = "ulEvResetMib" |
| 46 | ulEvGetVendorAndSerial = "ulEvGetVendorAndSerial" |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 47 | ulEvGetEquipmentID = "ulEvGetEquipmentId" |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 48 | ulEvGetFirstSwVersion = "ulEvGetFirstSwVersion" |
| 49 | ulEvGetSecondSwVersion = "ulEvGetSecondSwVersion" |
| 50 | ulEvGetMacAddress = "ulEvGetMacAddress" |
| 51 | ulEvGetMibTemplate = "ulEvGetMibTemplate" |
| 52 | ulEvUploadMib = "ulEvUploadMib" |
| 53 | ulEvExamineMds = "ulEvExamineMds" |
| 54 | ulEvSuccess = "ulEvSuccess" |
| 55 | ulEvMismatch = "ulEvMismatch" |
| 56 | ulEvAuditMib = "ulEvAuditMib" |
| 57 | ulEvForceResync = "ulEvForceResync" |
| 58 | ulEvDiffsFound = "ulEvDiffsFound" |
| 59 | ulEvTimeout = "ulEvTimeout" |
| 60 | ulEvStop = "ulEvStop" |
| 61 | ) |
| 62 | const ( |
| 63 | // states of MibUpload FSM |
| 64 | ulStDisabled = "ulStDisabled" |
| 65 | ulStStarting = "ulStStarting" |
| 66 | ulStResettingMib = "ulStResettingMib" |
| 67 | ulStGettingVendorAndSerial = "ulStGettingVendorAndSerial" |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 68 | ulStGettingEquipmentID = "ulStGettingEquipmentID" |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 69 | ulStGettingFirstSwVersion = "ulStGettingFirstSwVersion" |
| 70 | ulStGettingSecondSwVersion = "ulStGettingSecondSwVersion" |
| 71 | ulStGettingMacAddress = "ulStGettingMacAddress" |
| 72 | ulStGettingMibTemplate = "ulStGettingMibTemplate" |
| 73 | ulStUploading = "ulStUploading" |
| 74 | ulStInSync = "ulStInSync" |
| 75 | ulStExaminingMds = "ulStExaminingMds" |
| 76 | ulStResynchronizing = "ulStResynchronizing" |
| 77 | ulStAuditing = "ulStAuditing" |
| 78 | ulStOutOfSync = "ulStOutOfSync" |
| 79 | ) |
| 80 | |
| 81 | const ( |
| 82 | // events of MibDownload FSM |
| 83 | dlEvStart = "dlEvStart" |
| 84 | dlEvCreateGal = "dlEvCreateGal" |
| 85 | dlEvRxGalResp = "dlEvRxGalResp" |
| 86 | dlEvRxOnu2gResp = "dlEvRxOnu2gResp" |
| 87 | dlEvRxBridgeResp = "dlEvRxBridgeResp" |
| 88 | dlEvTimeoutSimple = "dlEvTimeoutSimple" |
| 89 | dlEvTimeoutBridge = "dlEvTimeoutBridge" |
| 90 | dlEvReset = "dlEvReset" |
| 91 | dlEvRestart = "dlEvRestart" |
| 92 | ) |
| 93 | const ( |
| 94 | // states of MibDownload FSM |
| 95 | dlStDisabled = "dlStDisabled" |
| 96 | dlStStarting = "dlStStarting" |
| 97 | dlStCreatingGal = "dlStCreatingGal" |
| 98 | dlStSettingOnu2g = "dlStSettingOnu2g" |
| 99 | dlStBridgeInit = "dlStBridgeInit" |
| 100 | dlStDownloaded = "dlStDownloaded" |
| 101 | dlStResetting = "dlStResetting" |
| 102 | ) |
| 103 | |
| 104 | const ( |
Holger Hildebrandt | 2ff21f1 | 2020-08-13 14:38:02 +0000 | [diff] [blame] | 105 | cBasePathMibTemplateKvStore = "service/voltha/omci_mibs/go_templates" |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 106 | cSuffixMibTemplateKvStore = "%s/%s/%s" |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 107 | ) |
| 108 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 109 | // OnuDeviceEvent - event of interest to Device Adapters and OpenOMCI State Machines |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 110 | type OnuDeviceEvent int |
| 111 | |
| 112 | const ( |
| 113 | // Events of interest to Device Adapters and OpenOMCI State Machines |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 114 | |
| 115 | // DeviceStatusInit - default start state |
| 116 | DeviceStatusInit OnuDeviceEvent = 0 |
| 117 | // MibDatabaseSync - MIB database sync (upload done) |
| 118 | MibDatabaseSync OnuDeviceEvent = 1 |
| 119 | // OmciCapabilitiesDone - OMCI ME and message type capabilities known |
| 120 | OmciCapabilitiesDone OnuDeviceEvent = 2 |
| 121 | // MibDownloadDone - // MIB download done |
| 122 | MibDownloadDone OnuDeviceEvent = 3 |
| 123 | // UniLockStateDone - Uni ports admin set to lock |
| 124 | UniLockStateDone OnuDeviceEvent = 4 |
| 125 | // UniUnlockStateDone - Uni ports admin set to unlock |
| 126 | UniUnlockStateDone OnuDeviceEvent = 5 |
| 127 | // UniAdminStateDone - Uni ports admin set done - general |
| 128 | UniAdminStateDone OnuDeviceEvent = 6 |
| 129 | // PortLinkUp - Port link state change |
| 130 | PortLinkUp OnuDeviceEvent = 7 |
| 131 | // PortLinkDw - Port link state change |
| 132 | PortLinkDw OnuDeviceEvent = 8 |
| 133 | // OmciAniConfigDone - AniSide config according to TechProfile done |
| 134 | OmciAniConfigDone OnuDeviceEvent = 9 |
| 135 | // OmciVlanFilterDone - Omci Vlan config according to flowConfig done |
| 136 | OmciVlanFilterDone OnuDeviceEvent = 10 |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 137 | // Add other events here as needed (alarms separate???) |
| 138 | ) |
| 139 | |
| 140 | type activityDescr struct { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 141 | databaseClass func() error |
| 142 | //advertiseEvents bool |
| 143 | auditDelay uint16 |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 144 | //tasks map[string]func() error |
| 145 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 146 | |
| 147 | // OmciDeviceFsms - FSM event mapping to database class and time to wait between audits |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 148 | type OmciDeviceFsms map[string]activityDescr |
| 149 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 150 | // AdapterFsm - Adapter FSM details including channel, event and device |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 151 | type AdapterFsm struct { |
| 152 | fsmName string |
| 153 | deviceID string |
| 154 | commChan chan Message |
| 155 | pFsm *fsm.FSM |
| 156 | } |
| 157 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 158 | //NewAdapterFsm - FSM details including event, device and channel. |
| 159 | func NewAdapterFsm(aName string, aDeviceID string, aCommChannel chan Message) *AdapterFsm { |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 160 | aFsm := &AdapterFsm{ |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 161 | fsmName: aName, |
| 162 | deviceID: aDeviceID, |
| 163 | commChan: aCommChannel, |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 164 | } |
| 165 | return aFsm |
| 166 | } |
| 167 | |
| 168 | //Start starts (logs) the omci agent |
| 169 | func (oo *AdapterFsm) logFsmStateChange(e *fsm.Event) { |
| 170 | logger.Debugw("FSM state change", log.Fields{"device-id": oo.deviceID, "FSM name": oo.fsmName, |
| 171 | "event name": string(e.Event), "src state": string(e.Src), "dst state": string(e.Dst)}) |
| 172 | } |
| 173 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 174 | //OntDeviceEntry structure holds information about the attached FSM'as and their communication |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 175 | |
| 176 | const ( |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 177 | firstSwImageMeID = 0 |
| 178 | secondSwImageMeID = 1 |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 179 | ) |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 180 | const onugMeID = 0 |
| 181 | const onu2gMeID = 0 |
| 182 | const ipHostConfigDataMeID = 1 |
| 183 | const onugSerialNumberLen = 8 |
| 184 | const omciMacAddressLen = 6 |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 185 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 186 | type swImages struct { |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 187 | version string |
| 188 | isActive uint8 |
| 189 | } |
| 190 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 191 | // OnuDeviceEntry - ONU device info and FSM events. |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 192 | type OnuDeviceEntry struct { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 193 | deviceID string |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 194 | baseDeviceHandler *deviceHandler |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 195 | coreProxy adapterif.CoreProxy |
| 196 | adapterProxy adapterif.AdapterProxy |
| 197 | started bool |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 198 | PDevOmciCC *omciCC |
| 199 | pOnuDB *onuDeviceDB |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 200 | mibTemplateKVStore *db.Backend |
| 201 | vendorID string |
| 202 | serialNumber string |
| 203 | equipmentID string |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 204 | swImages [secondSwImageMeID + 1]swImages |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 205 | activeSwVersion string |
| 206 | macAddress string |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 207 | //lockDeviceEntries sync.RWMutex |
| 208 | mibDbClass func() error |
| 209 | supportedFsms OmciDeviceFsms |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 210 | devState OnuDeviceEvent |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 211 | // for mibUpload |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 212 | mibAuditDelay uint16 |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 213 | mibDebugLevel string |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 214 | |
| 215 | // for mibUpload |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 216 | pMibUploadFsm *AdapterFsm //could be handled dynamically and more general as pAdapterFsm - perhaps later |
| 217 | // for mibDownload |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 218 | pMibDownloadFsm *AdapterFsm //could be handled dynamically and more general as pAdapterFsm - perhaps later |
| 219 | //remark: general usage of pAdapterFsm would require generalization of commChan usage and internal event setting |
| 220 | // within the FSM event procedures |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 221 | omciMessageReceived chan bool //seperate channel needed by DownloadFsm |
| 222 | omciRebootMessageReceivedChannel chan Message // channel needed by Reboot request |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 223 | } |
| 224 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 225 | //newOnuDeviceEntry returns a new instance of a OnuDeviceEntry |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 226 | //mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!) |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 227 | func newOnuDeviceEntry(ctx context.Context, deviceID string, kVStoreHost string, kVStorePort int, kvStoreType string, deviceHandler *deviceHandler, |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 228 | coreProxy adapterif.CoreProxy, adapterProxy adapterif.AdapterProxy, |
| 229 | supportedFsmsPtr *OmciDeviceFsms) *OnuDeviceEntry { |
| 230 | logger.Infow("init-onuDeviceEntry", log.Fields{"device-id": deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 231 | var onuDeviceEntry OnuDeviceEntry |
| 232 | onuDeviceEntry.started = false |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 233 | onuDeviceEntry.deviceID = deviceID |
| 234 | onuDeviceEntry.baseDeviceHandler = deviceHandler |
| 235 | onuDeviceEntry.coreProxy = coreProxy |
| 236 | onuDeviceEntry.adapterProxy = adapterProxy |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 237 | onuDeviceEntry.devState = DeviceStatusInit |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 238 | onuDeviceEntry.omciRebootMessageReceivedChannel = make(chan Message, 2048) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 239 | //openomciagent.lockDeviceHandlersMap = sync.RWMutex{} |
| 240 | //OMCI related databases are on a per-agent basis. State machines and tasks |
| 241 | //are per ONU Vendor |
| 242 | // |
| 243 | // MIB Synchronization Database - possible overloading from arguments |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 244 | if supportedFsmsPtr != nil { |
| 245 | onuDeviceEntry.supportedFsms = *supportedFsmsPtr |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 246 | } else { |
| 247 | //var mibSyncFsm = NewMibSynchronizer() |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 248 | // use some internaö defaults, if not defined from outside |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 249 | onuDeviceEntry.supportedFsms = OmciDeviceFsms{ |
| 250 | "mib-synchronizer": { |
| 251 | //mibSyncFsm, // Implements the MIB synchronization state machine |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 252 | onuDeviceEntry.mibDbVolatileDict, // Implements volatile ME MIB database |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 253 | //true, // Advertise events on OpenOMCI event bus |
| 254 | 60, // Time to wait between MIB audits. 0 to disable audits. |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 255 | // map[string]func() error{ |
| 256 | // "mib-upload": onuDeviceEntry.MibUploadTask, |
| 257 | // "mib-template": onuDeviceEntry.MibTemplateTask, |
| 258 | // "get-mds": onuDeviceEntry.GetMdsTask, |
| 259 | // "mib-audit": onuDeviceEntry.GetMdsTask, |
| 260 | // "mib-resync": onuDeviceEntry.MibResyncTask, |
| 261 | // "mib-reconcile": onuDeviceEntry.MibReconcileTask, |
| 262 | // }, |
| 263 | }, |
| 264 | } |
| 265 | } |
| 266 | onuDeviceEntry.mibDbClass = onuDeviceEntry.supportedFsms["mib-synchronizer"].databaseClass |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 267 | logger.Debug("access2mibDbClass") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 268 | go onuDeviceEntry.mibDbClass() |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 269 | onuDeviceEntry.mibAuditDelay = onuDeviceEntry.supportedFsms["mib-synchronizer"].auditDelay |
| 270 | logger.Debugw("MibAudit is set to", log.Fields{"Delay": onuDeviceEntry.mibAuditDelay}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 271 | |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 272 | onuDeviceEntry.mibDebugLevel = "normal" //set to "verbose" if you want to have all output, possibly later also per config option! |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 273 | // Omci related Mib upload sync state machine |
| 274 | mibUploadChan := make(chan Message, 2048) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 275 | onuDeviceEntry.pMibUploadFsm = NewAdapterFsm("MibUpload", deviceID, mibUploadChan) |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 276 | onuDeviceEntry.pMibUploadFsm.pFsm = fsm.NewFSM( |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 277 | ulStDisabled, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 278 | fsm.Events{ |
| 279 | |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 280 | {Name: ulEvStart, Src: []string{ulStDisabled}, Dst: ulStStarting}, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 281 | |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 282 | {Name: ulEvResetMib, Src: []string{ulStStarting}, Dst: ulStResettingMib}, |
| 283 | {Name: ulEvGetVendorAndSerial, Src: []string{ulStResettingMib}, Dst: ulStGettingVendorAndSerial}, |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 284 | {Name: ulEvGetEquipmentID, Src: []string{ulStGettingVendorAndSerial}, Dst: ulStGettingEquipmentID}, |
| 285 | {Name: ulEvGetFirstSwVersion, Src: []string{ulStGettingEquipmentID}, Dst: ulStGettingFirstSwVersion}, |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 286 | {Name: ulEvGetSecondSwVersion, Src: []string{ulStGettingFirstSwVersion}, Dst: ulStGettingSecondSwVersion}, |
| 287 | {Name: ulEvGetMacAddress, Src: []string{ulStGettingSecondSwVersion}, Dst: ulStGettingMacAddress}, |
| 288 | {Name: ulEvGetMibTemplate, Src: []string{ulStGettingMacAddress}, Dst: ulStGettingMibTemplate}, |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 289 | |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 290 | {Name: ulEvUploadMib, Src: []string{ulStGettingMibTemplate}, Dst: ulStUploading}, |
| 291 | {Name: ulEvExamineMds, Src: []string{ulStStarting}, Dst: ulStExaminingMds}, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 292 | |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 293 | {Name: ulEvSuccess, Src: []string{ulStGettingMibTemplate}, Dst: ulStInSync}, |
| 294 | {Name: ulEvSuccess, Src: []string{ulStUploading}, Dst: ulStInSync}, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 295 | |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 296 | {Name: ulEvSuccess, Src: []string{ulStExaminingMds}, Dst: ulStInSync}, |
| 297 | {Name: ulEvMismatch, Src: []string{ulStExaminingMds}, Dst: ulStResynchronizing}, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 298 | |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 299 | {Name: ulEvAuditMib, Src: []string{ulStInSync}, Dst: ulStAuditing}, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 300 | |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 301 | {Name: ulEvSuccess, Src: []string{ulStOutOfSync}, Dst: ulStInSync}, |
| 302 | {Name: ulEvAuditMib, Src: []string{ulStOutOfSync}, Dst: ulStAuditing}, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 303 | |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 304 | {Name: ulEvSuccess, Src: []string{ulStAuditing}, Dst: ulStInSync}, |
| 305 | {Name: ulEvMismatch, Src: []string{ulStAuditing}, Dst: ulStResynchronizing}, |
| 306 | {Name: ulEvForceResync, Src: []string{ulStAuditing}, Dst: ulStResynchronizing}, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 307 | |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 308 | {Name: ulEvSuccess, Src: []string{ulStResynchronizing}, Dst: ulStInSync}, |
| 309 | {Name: ulEvDiffsFound, Src: []string{ulStResynchronizing}, Dst: ulStOutOfSync}, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 310 | |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 311 | {Name: ulEvTimeout, Src: []string{ulStResettingMib, ulStGettingVendorAndSerial, ulStGettingEquipmentID, ulStGettingFirstSwVersion, |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 312 | ulStGettingSecondSwVersion, ulStGettingMacAddress, ulStGettingMibTemplate, ulStUploading, ulStResynchronizing, ulStExaminingMds, |
| 313 | ulStInSync, ulStOutOfSync, ulStAuditing}, Dst: ulStStarting}, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 314 | |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 315 | {Name: ulEvStop, Src: []string{ulStStarting, ulStResettingMib, ulStGettingVendorAndSerial, ulStGettingEquipmentID, ulStGettingFirstSwVersion, |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 316 | ulStGettingSecondSwVersion, ulStGettingMacAddress, ulStGettingMibTemplate, ulStUploading, ulStResynchronizing, ulStExaminingMds, |
| 317 | ulStInSync, ulStOutOfSync, ulStAuditing}, Dst: ulStDisabled}, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 318 | }, |
| 319 | |
| 320 | fsm.Callbacks{ |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 321 | "enter_state": func(e *fsm.Event) { onuDeviceEntry.pMibUploadFsm.logFsmStateChange(e) }, |
| 322 | ("enter_" + ulStStarting): func(e *fsm.Event) { onuDeviceEntry.enterStartingState(e) }, |
| 323 | ("enter_" + ulStResettingMib): func(e *fsm.Event) { onuDeviceEntry.enterResettingMibState(e) }, |
| 324 | ("enter_" + ulStGettingVendorAndSerial): func(e *fsm.Event) { onuDeviceEntry.enterGettingVendorAndSerialState(e) }, |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 325 | ("enter_" + ulStGettingEquipmentID): func(e *fsm.Event) { onuDeviceEntry.enterGettingEquipmentIDState(e) }, |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 326 | ("enter_" + ulStGettingFirstSwVersion): func(e *fsm.Event) { onuDeviceEntry.enterGettingFirstSwVersionState(e) }, |
| 327 | ("enter_" + ulStGettingSecondSwVersion): func(e *fsm.Event) { onuDeviceEntry.enterGettingSecondSwVersionState(e) }, |
| 328 | ("enter_" + ulStGettingMacAddress): func(e *fsm.Event) { onuDeviceEntry.enterGettingMacAddressState(e) }, |
| 329 | ("enter_" + ulStGettingMibTemplate): func(e *fsm.Event) { onuDeviceEntry.enterGettingMibTemplate(e) }, |
| 330 | ("enter_" + ulStUploading): func(e *fsm.Event) { onuDeviceEntry.enterUploadingState(e) }, |
| 331 | ("enter_" + ulStExaminingMds): func(e *fsm.Event) { onuDeviceEntry.enterExaminingMdsState(e) }, |
| 332 | ("enter_" + ulStResynchronizing): func(e *fsm.Event) { onuDeviceEntry.enterResynchronizingState(e) }, |
| 333 | ("enter_" + ulStAuditing): func(e *fsm.Event) { onuDeviceEntry.enterAuditingState(e) }, |
| 334 | ("enter_" + ulStOutOfSync): func(e *fsm.Event) { onuDeviceEntry.enterOutOfSyncState(e) }, |
| 335 | ("enter_" + ulStInSync): func(e *fsm.Event) { onuDeviceEntry.enterInSyncState(e) }, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 336 | }, |
| 337 | ) |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 338 | // Omci related Mib download state machine |
| 339 | mibDownloadChan := make(chan Message, 2048) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 340 | onuDeviceEntry.pMibDownloadFsm = NewAdapterFsm("MibDownload", deviceID, mibDownloadChan) |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 341 | onuDeviceEntry.pMibDownloadFsm.pFsm = fsm.NewFSM( |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 342 | dlStDisabled, |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 343 | fsm.Events{ |
| 344 | |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 345 | {Name: dlEvStart, Src: []string{dlStDisabled}, Dst: dlStStarting}, |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 346 | |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 347 | {Name: dlEvCreateGal, Src: []string{dlStStarting}, Dst: dlStCreatingGal}, |
| 348 | {Name: dlEvRxGalResp, Src: []string{dlStCreatingGal}, Dst: dlStSettingOnu2g}, |
| 349 | {Name: dlEvRxOnu2gResp, Src: []string{dlStSettingOnu2g}, Dst: dlStBridgeInit}, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 350 | // the bridge state is used for multi ME config for alle UNI related ports |
| 351 | // maybe such could be reflected in the state machine as well (port number parametrized) |
| 352 | // but that looks not straightforward here - so we keep it simple here for the beginning(?) |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 353 | {Name: dlEvRxBridgeResp, Src: []string{dlStBridgeInit}, Dst: dlStDownloaded}, |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 354 | |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 355 | {Name: dlEvTimeoutSimple, Src: []string{dlStCreatingGal, dlStSettingOnu2g}, Dst: dlStStarting}, |
| 356 | {Name: dlEvTimeoutBridge, Src: []string{dlStBridgeInit}, Dst: dlStStarting}, |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 357 | |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 358 | {Name: dlEvReset, Src: []string{dlStStarting, dlStCreatingGal, dlStSettingOnu2g, |
| 359 | dlStBridgeInit, dlStDownloaded}, Dst: dlStResetting}, |
| 360 | // exceptional treatment for all states except dlStResetting |
| 361 | {Name: dlEvRestart, Src: []string{dlStStarting, dlStCreatingGal, dlStSettingOnu2g, |
| 362 | dlStBridgeInit, dlStDownloaded, dlStResetting}, Dst: dlStDisabled}, |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 363 | }, |
| 364 | |
| 365 | fsm.Callbacks{ |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 366 | "enter_state": func(e *fsm.Event) { onuDeviceEntry.pMibDownloadFsm.logFsmStateChange(e) }, |
| 367 | ("enter_" + dlStStarting): func(e *fsm.Event) { onuDeviceEntry.enterDLStartingState(e) }, |
| 368 | ("enter_" + dlStCreatingGal): func(e *fsm.Event) { onuDeviceEntry.enterCreatingGalState(e) }, |
| 369 | ("enter_" + dlStSettingOnu2g): func(e *fsm.Event) { onuDeviceEntry.enterSettingOnu2gState(e) }, |
| 370 | ("enter_" + dlStBridgeInit): func(e *fsm.Event) { onuDeviceEntry.enterBridgeInitState(e) }, |
| 371 | ("enter_" + dlStDownloaded): func(e *fsm.Event) { onuDeviceEntry.enterDownloadedState(e) }, |
| 372 | ("enter_" + dlStResetting): func(e *fsm.Event) { onuDeviceEntry.enterResettingState(e) }, |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 373 | }, |
| 374 | ) |
| 375 | if onuDeviceEntry.pMibDownloadFsm == nil || onuDeviceEntry.pMibDownloadFsm.pFsm == nil { |
| 376 | logger.Error("MibDownloadFsm could not be instantiated!!") |
| 377 | // some specifc error treatment - or waiting for crash ??? |
| 378 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 379 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 380 | onuDeviceEntry.mibTemplateKVStore = onuDeviceEntry.baseDeviceHandler.setBackend(cBasePathMibTemplateKvStore) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 381 | if onuDeviceEntry.mibTemplateKVStore == nil { |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 382 | logger.Errorw("Failed to setup mibTemplateKVStore", log.Fields{"device-id": deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 383 | } |
| 384 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 385 | // Alarm Synchronization Database |
| 386 | //self._alarm_db = None |
| 387 | //self._alarm_database_cls = support_classes['alarm-synchronizer']['database'] |
| 388 | return &onuDeviceEntry |
| 389 | } |
| 390 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 391 | //start starts (logs) the omci agent |
| 392 | func (oo *OnuDeviceEntry) start(ctx context.Context) error { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 393 | logger.Info("starting-OnuDeviceEntry") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 394 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 395 | oo.PDevOmciCC = newOmciCC(ctx, oo, oo.deviceID, oo.baseDeviceHandler, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 396 | oo.coreProxy, oo.adapterProxy) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 397 | if oo.PDevOmciCC == nil { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 398 | logger.Errorw("Could not create devOmciCc - abort", log.Fields{"for device-id": oo.deviceID}) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 399 | return errors.New("could not create devOmciCc") |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 400 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 401 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 402 | oo.started = true |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 403 | logger.Info("OnuDeviceEntry-started") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 404 | return nil |
| 405 | } |
| 406 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 407 | //stop terminates the session |
| 408 | func (oo *OnuDeviceEntry) stop(ctx context.Context) error { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 409 | logger.Info("stopping-OnuDeviceEntry") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 410 | oo.started = false |
| 411 | //oo.exitChannel <- 1 |
mpagenko | 3af1f03 | 2020-06-10 08:53:41 +0000 | [diff] [blame] | 412 | // maybe also the omciCC should be stopped here - for now not as no real processing is expected here - maybe needs consolidation |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 413 | logger.Info("OnuDeviceEntry-stopped") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 414 | return nil |
| 415 | } |
| 416 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 417 | func (oo *OnuDeviceEntry) reboot(ctx context.Context) error { |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 418 | logger.Info("reboot-OnuDeviceEntry") |
| 419 | if err := oo.PDevOmciCC.sendReboot(context.TODO(), ConstDefaultOmciTimeout, true, oo.omciRebootMessageReceivedChannel); err != nil { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 420 | logger.Errorw("onu didn't reboot", log.Fields{"for device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 421 | return err |
| 422 | } |
| 423 | logger.Info("OnuDeviceEntry-reboot") |
| 424 | return nil |
| 425 | } |
| 426 | |
| 427 | func (oo *OnuDeviceEntry) waitForRebootResponse(responseChannel chan Message) error { |
| 428 | select { |
| 429 | case <-time.After(3 * time.Second): //3s was detected to be to less in 8*8 bbsim test with debug Info/Debug |
| 430 | logger.Warnw("Reboot timeout", log.Fields{"for device-id": oo.deviceID}) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 431 | return errors.New("rebootTimeout") |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 432 | case data := <-responseChannel: |
| 433 | switch data.Data.(OmciMessage).OmciMsg.MessageType { |
| 434 | case omci.RebootResponseType: |
| 435 | { |
| 436 | msgLayer := (*data.Data.(OmciMessage).OmciPacket).Layer(omci.LayerTypeRebootResponse) |
| 437 | if msgLayer == nil { |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 438 | return errors.New("omci Msg layer could not be detected for RebootResponseType") |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 439 | } |
| 440 | msgObj, msgOk := msgLayer.(*omci.GetResponse) |
| 441 | if !msgOk { |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 442 | return errors.New("omci Msg layer could not be assigned for RebootResponseType") |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 443 | } |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 444 | logger.Debugw("CreateResponse Data", log.Fields{"device-id": oo.deviceID, "data-fields": msgObj}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 445 | if msgObj.Result != me.Success { |
| 446 | logger.Errorw("Omci RebootResponseType Error ", log.Fields{"Error": msgObj.Result}) |
| 447 | // possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display? |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 448 | return errors.New("omci RebootResponse Result Error indication") |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 449 | } |
| 450 | return nil |
| 451 | } |
| 452 | } |
| 453 | logger.Warnw("Reboot response error", log.Fields{"for device-id": oo.deviceID}) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 454 | return errors.New("unexpected OmciResponse type received") |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 455 | } |
| 456 | } |
| 457 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 458 | //Relay the InSync message via Handler to Rw core - Status update |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 459 | func (oo *OnuDeviceEntry) transferSystemEvent(devEvent OnuDeviceEvent) { |
| 460 | logger.Debugw("relaying system-event", log.Fields{"Event": devEvent}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 461 | // decouple the handler transfer from further processing here |
| 462 | // TODO!!! check if really no synch is required within the system e.g. to ensure following steps .. |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 463 | if devEvent == MibDatabaseSync { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 464 | if oo.devState < MibDatabaseSync { //devState has not been synced yet |
| 465 | oo.devState = MibDatabaseSync |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 466 | go oo.baseDeviceHandler.deviceProcStatusUpdate(devEvent) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 467 | //TODO!!! device control: next step: start MIB capability verification from here ?!!! |
| 468 | } else { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 469 | logger.Debugw("mibinsync-event in some already synced state - ignored", log.Fields{"state": oo.devState}) |
| 470 | } |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 471 | } else if devEvent == MibDownloadDone { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 472 | if oo.devState < MibDownloadDone { //devState has not been synced yet |
| 473 | oo.devState = MibDownloadDone |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 474 | go oo.baseDeviceHandler.deviceProcStatusUpdate(devEvent) |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 475 | } else { |
| 476 | logger.Debugw("mibdownloaddone-event was already seen - ignored", log.Fields{"state": oo.devState}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 477 | } |
| 478 | } else { |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 479 | logger.Warnw("device-event not yet handled", log.Fields{"state": devEvent}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 480 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 481 | } |