Loading go-apps/meep-sss/api/swagger.yaml +2 −2 Original line number Diff line number Diff line Loading @@ -411,7 +411,7 @@ paths: description: "This method shall support the URI query parameter, request and\ \ response data structures, and response codes, as specified in Tables 7.7.3.1-1\ \ and 7.7.3.1-2" operationId: SensorStatusIndividualSubscriptionGET operationId: SensorStatusSubscriptionGET parameters: - name: sensorIdentifier in: query Loading Loading @@ -510,7 +510,7 @@ paths: summary: The GET method is used to retrieve information about this subscription description: "This method shall support the request and response data structures,\ \ and response codes, as specified in Tables 7.8.3.1-1 and 7.8.3.1-2" operationId: SensorSatusIndividualSubscriptionGET operationId: SensorStatusIndividualSubscriptionGET parameters: - name: subscriptionId in: path Loading go-apps/meep-sss/sbi/sss-sbi.go +126 −23 Original line number Diff line number Diff line Loading @@ -28,19 +28,41 @@ import ( const moduleName string = "meep-sss-sbi" // var redisAddr string = "meep-redis-master.default.svc.cluster.local:6379" // var influxAddr string = "http://meep-influxdb.default.svc.cluster.local:8086" type Point struct { Latitude float64 Longitude float64 } type SensorCharacteristic struct { CharacteristicName string CharacteristicValue string CharacteristicUnitOfMeasure *string } type SensorDiscoveryInfo struct { SensorIdentifier string SensorType string SensorPropertyList []string SensorCharacteristicList []SensorCharacteristic SensorPosition *Point } type SensorStatusInfo struct { SensorIdentifier string SensorStatusType string ErrorInformation string } type SbiCfg struct { ModuleName string SandboxName string IotBroker string IotTopic string MepName string RedisAddr string InfluxAddr string Locality []string IotNotify func(string, string) DiscoveryNotify func() StatusNotify func() DataNotify func() ScenarioNameCb func(string) CleanUpCb func() } Loading @@ -56,7 +78,10 @@ type SssSbi struct { handlerId int apiMgr *sam.SwaggerApiMgr activeModel *mod.Model iotMgr *tm.IotMgr sssMgr *tm.SssMgr discoveryNotify func() statusNotify func() dataNotify func() updateScenarioNameCB func(string) cleanUpCB func() mutex sync.Mutex Loading @@ -64,7 +89,7 @@ type SssSbi struct { var sbi *SssSbi // Init - IOT Service SBI initialization // Init - SSS Service SBI initialization func Init(cfg SbiCfg) (err error) { // Create new SBI instance Loading @@ -78,6 +103,9 @@ func Init(cfg SbiCfg) (err error) { sbi.scenarioName = "" sbi.updateScenarioNameCB = cfg.ScenarioNameCb sbi.cleanUpCB = cfg.CleanUpCb sbi.discoveryNotify = cfg.DiscoveryNotify sbi.statusNotify = cfg.StatusNotify sbi.dataNotify = cfg.DataNotify // Fill locality map if len(cfg.Locality) > 0 { Loading Loading @@ -120,13 +148,13 @@ func Init(cfg SbiCfg) (err error) { return err } // Connect to IOT Manager sbi.iotMgr, err = tm.NewOneM2MMgr(sbi.moduleName, sbi.sandboxName) // Connect to SSS Manager sbi.sssMgr, err = tm.NewSssMgr(sbi.moduleName, sbi.sandboxName, sbi.discoveryNotify, sbi.statusNotify, sbi.dataNotify) if err != nil { log.Error("Failed connection to OneM2M Manager: ", err) log.Error("Failed connection to SSS Manager: ", err) return err } log.Info("Connected to OneM2M Manager") log.Info("Connected to SSS Manager") // Initialize service processActiveScenarioUpdate() Loading @@ -134,7 +162,7 @@ func Init(cfg SbiCfg) (err error) { return nil } // Run - MEEP IOT execution // Run - MEEP SSS execution func Run() (err error) { // Start Swagger API Manager (provider) Loading Loading @@ -182,9 +210,9 @@ func Stop() (err error) { } } // Delete IOT Manager if sbi.iotMgr != nil { err = sbi.iotMgr.DeleteIotMgr() // Delete SSS Manager if sbi.sssMgr != nil { err = sbi.sssMgr.DeleteSssMgr() if err != nil { log.Error(err.Error()) return err Loading Loading @@ -245,3 +273,78 @@ func processActiveScenarioUpdate() { // } } } func SensorDiscoveryInfoAll() (sensors []SensorDiscoveryInfo, err error) { log.Info("sbi.SensorDiscoveryInfoAll") s, err := sbi.sssMgr.SensorDiscoveryInfoAll() if err != nil { return nil, err } //log.Info("sbi.SensorDiscoveryInfoAll: s: ", s) sensors = convertSensorDiscoveryInfoListFromSssMgr(s) log.Info("sbi.SensorDiscoveryInfoAll: sensors: ", sensors) return sensors, nil } func GetSensorStatus(sensorIdentifier string) (status SensorStatusInfo, err error) { log.Info("sbi.GetSensorStatus") s, err := sbi.sssMgr.GetSensor(sensorIdentifier) if err != nil { return status, err } log.Info("sbi.GetSensorStatus: s: ", s) sensor := convertSensorDiscoveryInfoFromSssMgr(s) log.Info("sbi.GetSensorStatus: sensors: ", sensor) // FIXME FSCOM CHeck status of the sensor??? status = SensorStatusInfo{ SensorIdentifier: sensor.SensorIdentifier, SensorStatusType: "ONLINE", ErrorInformation: "", } return status, nil } func convertSensorDiscoveryInfoListFromSssMgr(s []tm.SensorDiscoveryInfo) (sensors []SensorDiscoveryInfo) { sensors = make([]SensorDiscoveryInfo, len(s)) for i, val := range s { sensors[i] = convertSensorDiscoveryInfoFromSssMgr(val) } // End of 'for' statement return sensors } func convertSensorDiscoveryInfoFromSssMgr(s tm.SensorDiscoveryInfo) (sensor SensorDiscoveryInfo) { sensor = SensorDiscoveryInfo{ SensorIdentifier: s.SensorIdentifier, SensorType: s.SensorType, } if len(s.SensorPropertyList) != 0 { sensor.SensorPropertyList = make([]string, len(s.SensorPropertyList)) copy(sensor.SensorPropertyList, s.SensorPropertyList) } if len(s.SensorCharacteristicList) != 0 { sensor.SensorCharacteristicList = make([]SensorCharacteristic, len(s.SensorCharacteristicList)) for i, val := range s.SensorCharacteristicList { sensor.SensorCharacteristicList[i] = SensorCharacteristic{ CharacteristicName: val.CharacteristicName, CharacteristicValue: val.CharacteristicValue, CharacteristicUnitOfMeasure: val.CharacteristicUnitOfMeasure, } } // End of 'for' statement } if s.SensorPosition != nil { sensor.SensorPosition = &Point{ Latitude: s.SensorPosition.Latitude, Longitude: s.SensorPosition.Longitude, } } return sensor } go-apps/meep-sss/server/api_sensor_data_subscription.go +4 −8 Original line number Diff line number Diff line Loading @@ -14,23 +14,19 @@ import ( ) func SensorDataIndividualSubscriptionGET(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) sensorDataIndividualSubscriptionGET(w, r) } func SensorDataSubscriptionDELETE(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) sensorDataSubscriptionDELETE(w, r) } func SensorDataSubscriptionGET(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) sensorDataSubscriptionGET(w, r) } func SensorDataSubscriptionPOST(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) sensorDataSubscriptionPOST(w, r) } func SensorDataSubscriptionPUT(w http.ResponseWriter, r *http.Request) { Loading go-apps/meep-sss/server/api_sensor_discovery_subscription.go +3 −6 Original line number Diff line number Diff line Loading @@ -14,13 +14,11 @@ import ( ) func SensorDiscoveryIndividualSubscriptionGET(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) sensorDiscoveryIndividualSubscriptionGET(w, r) } func SensorDiscoverySubscriptionDELETE(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) sensorDiscoverySubscriptionDELETE(w, r) } func SensorDiscoverySubscriptionGET(w http.ResponseWriter, r *http.Request) { Loading @@ -28,8 +26,7 @@ func SensorDiscoverySubscriptionGET(w http.ResponseWriter, r *http.Request) { } func SensorDiscoverySubscriptionPOST(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) sensorDiscoverySubscriptionPOST(w, r) } func SensorDiscoverySubscriptionPUT(w http.ResponseWriter, r *http.Request) { Loading go-apps/meep-sss/server/api_sensor_status_lookup.go +1 −2 Original line number Diff line number Diff line Loading @@ -14,6 +14,5 @@ import ( ) func SensorStatusLookupGET(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) sensorStatusLookupGET(w, r) } Loading
go-apps/meep-sss/api/swagger.yaml +2 −2 Original line number Diff line number Diff line Loading @@ -411,7 +411,7 @@ paths: description: "This method shall support the URI query parameter, request and\ \ response data structures, and response codes, as specified in Tables 7.7.3.1-1\ \ and 7.7.3.1-2" operationId: SensorStatusIndividualSubscriptionGET operationId: SensorStatusSubscriptionGET parameters: - name: sensorIdentifier in: query Loading Loading @@ -510,7 +510,7 @@ paths: summary: The GET method is used to retrieve information about this subscription description: "This method shall support the request and response data structures,\ \ and response codes, as specified in Tables 7.8.3.1-1 and 7.8.3.1-2" operationId: SensorSatusIndividualSubscriptionGET operationId: SensorStatusIndividualSubscriptionGET parameters: - name: subscriptionId in: path Loading
go-apps/meep-sss/sbi/sss-sbi.go +126 −23 Original line number Diff line number Diff line Loading @@ -28,19 +28,41 @@ import ( const moduleName string = "meep-sss-sbi" // var redisAddr string = "meep-redis-master.default.svc.cluster.local:6379" // var influxAddr string = "http://meep-influxdb.default.svc.cluster.local:8086" type Point struct { Latitude float64 Longitude float64 } type SensorCharacteristic struct { CharacteristicName string CharacteristicValue string CharacteristicUnitOfMeasure *string } type SensorDiscoveryInfo struct { SensorIdentifier string SensorType string SensorPropertyList []string SensorCharacteristicList []SensorCharacteristic SensorPosition *Point } type SensorStatusInfo struct { SensorIdentifier string SensorStatusType string ErrorInformation string } type SbiCfg struct { ModuleName string SandboxName string IotBroker string IotTopic string MepName string RedisAddr string InfluxAddr string Locality []string IotNotify func(string, string) DiscoveryNotify func() StatusNotify func() DataNotify func() ScenarioNameCb func(string) CleanUpCb func() } Loading @@ -56,7 +78,10 @@ type SssSbi struct { handlerId int apiMgr *sam.SwaggerApiMgr activeModel *mod.Model iotMgr *tm.IotMgr sssMgr *tm.SssMgr discoveryNotify func() statusNotify func() dataNotify func() updateScenarioNameCB func(string) cleanUpCB func() mutex sync.Mutex Loading @@ -64,7 +89,7 @@ type SssSbi struct { var sbi *SssSbi // Init - IOT Service SBI initialization // Init - SSS Service SBI initialization func Init(cfg SbiCfg) (err error) { // Create new SBI instance Loading @@ -78,6 +103,9 @@ func Init(cfg SbiCfg) (err error) { sbi.scenarioName = "" sbi.updateScenarioNameCB = cfg.ScenarioNameCb sbi.cleanUpCB = cfg.CleanUpCb sbi.discoveryNotify = cfg.DiscoveryNotify sbi.statusNotify = cfg.StatusNotify sbi.dataNotify = cfg.DataNotify // Fill locality map if len(cfg.Locality) > 0 { Loading Loading @@ -120,13 +148,13 @@ func Init(cfg SbiCfg) (err error) { return err } // Connect to IOT Manager sbi.iotMgr, err = tm.NewOneM2MMgr(sbi.moduleName, sbi.sandboxName) // Connect to SSS Manager sbi.sssMgr, err = tm.NewSssMgr(sbi.moduleName, sbi.sandboxName, sbi.discoveryNotify, sbi.statusNotify, sbi.dataNotify) if err != nil { log.Error("Failed connection to OneM2M Manager: ", err) log.Error("Failed connection to SSS Manager: ", err) return err } log.Info("Connected to OneM2M Manager") log.Info("Connected to SSS Manager") // Initialize service processActiveScenarioUpdate() Loading @@ -134,7 +162,7 @@ func Init(cfg SbiCfg) (err error) { return nil } // Run - MEEP IOT execution // Run - MEEP SSS execution func Run() (err error) { // Start Swagger API Manager (provider) Loading Loading @@ -182,9 +210,9 @@ func Stop() (err error) { } } // Delete IOT Manager if sbi.iotMgr != nil { err = sbi.iotMgr.DeleteIotMgr() // Delete SSS Manager if sbi.sssMgr != nil { err = sbi.sssMgr.DeleteSssMgr() if err != nil { log.Error(err.Error()) return err Loading Loading @@ -245,3 +273,78 @@ func processActiveScenarioUpdate() { // } } } func SensorDiscoveryInfoAll() (sensors []SensorDiscoveryInfo, err error) { log.Info("sbi.SensorDiscoveryInfoAll") s, err := sbi.sssMgr.SensorDiscoveryInfoAll() if err != nil { return nil, err } //log.Info("sbi.SensorDiscoveryInfoAll: s: ", s) sensors = convertSensorDiscoveryInfoListFromSssMgr(s) log.Info("sbi.SensorDiscoveryInfoAll: sensors: ", sensors) return sensors, nil } func GetSensorStatus(sensorIdentifier string) (status SensorStatusInfo, err error) { log.Info("sbi.GetSensorStatus") s, err := sbi.sssMgr.GetSensor(sensorIdentifier) if err != nil { return status, err } log.Info("sbi.GetSensorStatus: s: ", s) sensor := convertSensorDiscoveryInfoFromSssMgr(s) log.Info("sbi.GetSensorStatus: sensors: ", sensor) // FIXME FSCOM CHeck status of the sensor??? status = SensorStatusInfo{ SensorIdentifier: sensor.SensorIdentifier, SensorStatusType: "ONLINE", ErrorInformation: "", } return status, nil } func convertSensorDiscoveryInfoListFromSssMgr(s []tm.SensorDiscoveryInfo) (sensors []SensorDiscoveryInfo) { sensors = make([]SensorDiscoveryInfo, len(s)) for i, val := range s { sensors[i] = convertSensorDiscoveryInfoFromSssMgr(val) } // End of 'for' statement return sensors } func convertSensorDiscoveryInfoFromSssMgr(s tm.SensorDiscoveryInfo) (sensor SensorDiscoveryInfo) { sensor = SensorDiscoveryInfo{ SensorIdentifier: s.SensorIdentifier, SensorType: s.SensorType, } if len(s.SensorPropertyList) != 0 { sensor.SensorPropertyList = make([]string, len(s.SensorPropertyList)) copy(sensor.SensorPropertyList, s.SensorPropertyList) } if len(s.SensorCharacteristicList) != 0 { sensor.SensorCharacteristicList = make([]SensorCharacteristic, len(s.SensorCharacteristicList)) for i, val := range s.SensorCharacteristicList { sensor.SensorCharacteristicList[i] = SensorCharacteristic{ CharacteristicName: val.CharacteristicName, CharacteristicValue: val.CharacteristicValue, CharacteristicUnitOfMeasure: val.CharacteristicUnitOfMeasure, } } // End of 'for' statement } if s.SensorPosition != nil { sensor.SensorPosition = &Point{ Latitude: s.SensorPosition.Latitude, Longitude: s.SensorPosition.Longitude, } } return sensor }
go-apps/meep-sss/server/api_sensor_data_subscription.go +4 −8 Original line number Diff line number Diff line Loading @@ -14,23 +14,19 @@ import ( ) func SensorDataIndividualSubscriptionGET(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) sensorDataIndividualSubscriptionGET(w, r) } func SensorDataSubscriptionDELETE(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) sensorDataSubscriptionDELETE(w, r) } func SensorDataSubscriptionGET(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) sensorDataSubscriptionGET(w, r) } func SensorDataSubscriptionPOST(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) sensorDataSubscriptionPOST(w, r) } func SensorDataSubscriptionPUT(w http.ResponseWriter, r *http.Request) { Loading
go-apps/meep-sss/server/api_sensor_discovery_subscription.go +3 −6 Original line number Diff line number Diff line Loading @@ -14,13 +14,11 @@ import ( ) func SensorDiscoveryIndividualSubscriptionGET(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) sensorDiscoveryIndividualSubscriptionGET(w, r) } func SensorDiscoverySubscriptionDELETE(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) sensorDiscoverySubscriptionDELETE(w, r) } func SensorDiscoverySubscriptionGET(w http.ResponseWriter, r *http.Request) { Loading @@ -28,8 +26,7 @@ func SensorDiscoverySubscriptionGET(w http.ResponseWriter, r *http.Request) { } func SensorDiscoverySubscriptionPOST(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) sensorDiscoverySubscriptionPOST(w, r) } func SensorDiscoverySubscriptionPUT(w http.ResponseWriter, r *http.Request) { Loading
go-apps/meep-sss/server/api_sensor_status_lookup.go +1 −2 Original line number Diff line number Diff line Loading @@ -14,6 +14,5 @@ import ( ) func SensorStatusLookupGET(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) sensorStatusLookupGET(w, r) }