Loading examples/demo9/golang/main.go +344 −327 File changed.Preview size limit exceeded, changes collapsed. Show changes examples/demo9/golang/routers.go +0 −6 Original line number Diff line number Diff line Loading @@ -65,10 +65,4 @@ var routes = HttpRoutes{ "/", Index, }, HttpRoute{ "fed_notification", "POST", "/fed/v1/notification", fed_notification, }, } go-apps/meep-iot/sbi/iot-sbi.go +8 −8 Original line number Diff line number Diff line Loading @@ -441,13 +441,13 @@ func GetDevices() (devices []DeviceInfo, err error) { if err != nil { return nil, err } //log.Info("sbi.GetDevices: dev: ", dev) log.Info("sbi.GetDevices: dev: ", dev) devices, err = convertDeviceInfosFromIotMgr(dev) if err != nil { return nil, err } //log.Info("sbi.GetDevices: devices: ", devices) log.Info("sbi.GetDevices: devices: ", devices) return devices, nil } Loading Loading @@ -567,7 +567,7 @@ func convertIotPlatformInfoToIotMgr(val IotPlatformInfo) (item tm.IotPlatformInf } func convertDeviceInfoFromIotMgr(dev tm.DeviceInfo) (device DeviceInfo) { //log.Debug(">>> convertDeviceInfoFromIotMgr") log.Debug(">>> convertDeviceInfoFromIotMgr") device = DeviceInfo{ DeviceAuthenticationInfo: dev.DeviceAuthenticationInfo, Loading Loading @@ -685,25 +685,25 @@ func convertDeviceInfoFromIotMgr(dev tm.DeviceInfo) (device DeviceInfo) { } } //log.Debug("convertDeviceInfoFromIotMgr: device: ", device) log.Debug("convertDeviceInfoFromIotMgr: device: ", device) return device } func convertDeviceInfosFromIotMgr(devicesList []tm.DeviceInfo) (devices []DeviceInfo, err error) { //log.Debug(">>> convertDeviceInfosFromIotMgr") log.Debug(">>> convertDeviceInfosFromIotMgr") devices = make([]DeviceInfo, len(devicesList)) for idx, item := range devicesList { // FIXME FSCOM Add Filter devices[idx] = convertDeviceInfoFromIotMgr(item) } // End of 'for' statement //log.Debug("convertDeviceInfosFromIotMgr: devices: ", devices) log.Debug("convertDeviceInfosFromIotMgr: devices: ", devices) return devices, nil } func convertDeviceInfoToIotMgr(dev DeviceInfo) (device tm.DeviceInfo) { //log.Debug(">>> convertDeviceInfoToIotMgr") log.Debug(">>> convertDeviceInfoToIotMgr") device = tm.DeviceInfo{ DeviceAuthenticationInfo: dev.DeviceAuthenticationInfo, Loading Loading @@ -820,7 +820,7 @@ func convertDeviceInfoToIotMgr(dev DeviceInfo) (device tm.DeviceInfo) { DevicePort: dev.DownlinkInfo.DevicePort, } } //log.Debug("convertDeviceInfoToIotMgr: device: ", device) log.Debug("convertDeviceInfoToIotMgr: device: ", device) return device } go-packages/meep-iot-mgr/iot-mgr.go +16 −5 Original line number Diff line number Diff line Loading @@ -311,12 +311,13 @@ func (tm *IotMgr) RegisterIotPlatformInfo(iotPlatformInfo IotPlatformInfo) (err log.Info(">>> RegisterIotPlatformInfo: iotPlatformId: ", iotPlatformInfo) if iotPlatformInfo.Enabled { iotPlatformInfo.oneM2M = nil if len(iotPlatformInfo.UserTransportInfo) == 0 || iotPlatformInfo.UserTransportInfo[0].Endpoint == nil || len(iotPlatformInfo.UserTransportInfo[0].Endpoint.Addresses) == 0 { // if len(iotPlatformInfo.UserTransportInfo) == 0 || iotPlatformInfo.UserTransportInfo[0].Endpoint == nil || len(iotPlatformInfo.UserTransportInfo[0].Endpoint.Addresses) == 0 { if len(iotPlatformInfo.CustomServicesTransportInfo) == 0 || iotPlatformInfo.CustomServicesTransportInfo[0].Endpoint == nil || len(iotPlatformInfo.UserTransportInfo[0].Endpoint.Addresses) == 0 { log.Warn("RegisterIotPlatformInfo: Cannot use provided CustomServicesTransportInfo") } else { // FIXME FSCOM How to get the CSE_ID. For the time being, iotPlatformInfo.UserTransportInfo[0].Name is the CSE-resourceID // TODO FSCOM Add notification support? pltf, err := sssmgr.NewSssMgr(tm.name, tm.namespace, iotPlatformInfo.UserTransportInfo[0].Protocol, iotPlatformInfo.UserTransportInfo[0].Endpoint.Addresses[0].Host, int(iotPlatformInfo.UserTransportInfo[0].Endpoint.Addresses[0].Port), iotPlatformInfo.IotPlatformId, iotPlatformInfo.UserTransportInfo[0].Name, nil, nil, nil) pltf, err := sssmgr.NewSssMgr(tm.name, tm.namespace, iotPlatformInfo.CustomServicesTransportInfo[0].Protocol, iotPlatformInfo.CustomServicesTransportInfo[0].Endpoint.Addresses[0].Host, int(iotPlatformInfo.CustomServicesTransportInfo[0].Endpoint.Addresses[0].Port), iotPlatformInfo.IotPlatformId, iotPlatformInfo.CustomServicesTransportInfo[0].Name, nil, nil, nil) if err != nil { log.Error("RegisterIotPlatformInfo: ", err) iotPlatformInfo.oneM2M = nil Loading Loading @@ -422,7 +423,7 @@ func (tm *IotMgr) GetDevices() (devices []DeviceInfo, err error) { return devices, nil } for _, v := range devicesMap { for _, v := range devicesMap { // Process all devices log.Info("GetDevices: adding device: ", v) devices = append(devices, v) } // End of 'for' statement Loading Loading @@ -664,13 +665,23 @@ func (tm *IotMgr) populateDevicesPerIotPlatforms(iotPlatformInfo IotPlatformInfo for _, sensor := range sensors { var deviceInfo = DeviceInfo{ DeviceId: sensor.SensorIdentifier, RequestedIotPlatformId: sensor.IotPlatformId, Enabled: true, } deviceInfo.DeviceMetadata = make([]KeyValuePair, len(sensor.SensorCharacteristicList)) for i, c := range sensor.SensorCharacteristicList { deviceInfo.DeviceMetadata[i] = KeyValuePair{Key: c.CharacteristicName, Value: c.CharacteristicValue} } // End of 'for' statement log.Info("populateDevicesPerIotPlatforms: len(sensor.Flex): ", len(sensor.Flex)) if len(sensor.Flex) != 0 { for k, v := range sensor.Flex { // Process all flex attributes log.Info("populateDevicesPerIotPlatforms: key: ", k) log.Info("populateDevicesPerIotPlatforms: value: ", v) deviceInfo.DeviceMetadata = append(deviceInfo.DeviceMetadata, KeyValuePair{Key: k, Value: v.(string)}) } // End of 'for' statement } log.Info("populateDevicesPerIotPlatforms: add deviceInfo: ", deviceInfo) devicesMap[deviceInfo.DeviceId] = deviceInfo devicesPerPlatformMap[iotPlatformInfo.IotPlatformId] = append(devicesPerPlatformMap[iotPlatformInfo.IotPlatformId], deviceInfo.DeviceId) } // End of 'for' statement Loading go-packages/meep-sss-mgr/onem2m-mgr.go +5 −4 Original line number Diff line number Diff line Loading @@ -428,7 +428,7 @@ func (tm *SssMgr) populateSensors(iotPlatformInfo IotPlatformInfo, type_ string) } sensorsMap[sensor.SensorIdentifier] = sensor //log.Info("populateSensors: After sensorsMap: ", sensorsMap) //log.Info("populateSensors: Before sensorsPerPlatformMap: ", sensorsPerPlatformMap) log.Info("populateSensors: Before sensorsPerPlatformMap: ", sensorsPerPlatformMap) if len(sensorsPerPlatformMap[sensor.IotPlatformId]) == 0 { sensorsPerPlatformMap[sensor.IotPlatformId] = append(sensorsPerPlatformMap[sensor.IotPlatformId], sensor.SensorIdentifier) } else { // Replace or add a new element Loading @@ -439,13 +439,14 @@ func (tm *SssMgr) populateSensors(iotPlatformInfo IotPlatformInfo, type_ string) break } } // End of 'for' statement log.Info("populateSensors: found idx: ", found) if found != -1 { // Replace sensorsPerPlatformMap[sensor.IotPlatformId] = append(sensorsPerPlatformMap[sensor.IotPlatformId][:found], sensorsPerPlatformMap[sensor.IotPlatformId][found+1:]...) } else { // Add sensorsPerPlatformMap[sensor.IotPlatformId] = append(sensorsPerPlatformMap[sensor.IotPlatformId], sensor.SensorIdentifier) } //log.Info("populateSensors: After sensorsPerPlatformMap: ", sensorsPerPlatformMap) // Add sensorsPerPlatformMap[sensor.IotPlatformId] = append(sensorsPerPlatformMap[sensor.IotPlatformId], sensor.SensorIdentifier) } log.Info("populateSensors: After sensorsPerPlatformMap: ", sensorsPerPlatformMap) } // End of 'for' statement log.Info("populateSensors: sensorsMap: ", sensorsMap) Loading Loading
examples/demo9/golang/main.go +344 −327 File changed.Preview size limit exceeded, changes collapsed. Show changes
examples/demo9/golang/routers.go +0 −6 Original line number Diff line number Diff line Loading @@ -65,10 +65,4 @@ var routes = HttpRoutes{ "/", Index, }, HttpRoute{ "fed_notification", "POST", "/fed/v1/notification", fed_notification, }, }
go-apps/meep-iot/sbi/iot-sbi.go +8 −8 Original line number Diff line number Diff line Loading @@ -441,13 +441,13 @@ func GetDevices() (devices []DeviceInfo, err error) { if err != nil { return nil, err } //log.Info("sbi.GetDevices: dev: ", dev) log.Info("sbi.GetDevices: dev: ", dev) devices, err = convertDeviceInfosFromIotMgr(dev) if err != nil { return nil, err } //log.Info("sbi.GetDevices: devices: ", devices) log.Info("sbi.GetDevices: devices: ", devices) return devices, nil } Loading Loading @@ -567,7 +567,7 @@ func convertIotPlatformInfoToIotMgr(val IotPlatformInfo) (item tm.IotPlatformInf } func convertDeviceInfoFromIotMgr(dev tm.DeviceInfo) (device DeviceInfo) { //log.Debug(">>> convertDeviceInfoFromIotMgr") log.Debug(">>> convertDeviceInfoFromIotMgr") device = DeviceInfo{ DeviceAuthenticationInfo: dev.DeviceAuthenticationInfo, Loading Loading @@ -685,25 +685,25 @@ func convertDeviceInfoFromIotMgr(dev tm.DeviceInfo) (device DeviceInfo) { } } //log.Debug("convertDeviceInfoFromIotMgr: device: ", device) log.Debug("convertDeviceInfoFromIotMgr: device: ", device) return device } func convertDeviceInfosFromIotMgr(devicesList []tm.DeviceInfo) (devices []DeviceInfo, err error) { //log.Debug(">>> convertDeviceInfosFromIotMgr") log.Debug(">>> convertDeviceInfosFromIotMgr") devices = make([]DeviceInfo, len(devicesList)) for idx, item := range devicesList { // FIXME FSCOM Add Filter devices[idx] = convertDeviceInfoFromIotMgr(item) } // End of 'for' statement //log.Debug("convertDeviceInfosFromIotMgr: devices: ", devices) log.Debug("convertDeviceInfosFromIotMgr: devices: ", devices) return devices, nil } func convertDeviceInfoToIotMgr(dev DeviceInfo) (device tm.DeviceInfo) { //log.Debug(">>> convertDeviceInfoToIotMgr") log.Debug(">>> convertDeviceInfoToIotMgr") device = tm.DeviceInfo{ DeviceAuthenticationInfo: dev.DeviceAuthenticationInfo, Loading Loading @@ -820,7 +820,7 @@ func convertDeviceInfoToIotMgr(dev DeviceInfo) (device tm.DeviceInfo) { DevicePort: dev.DownlinkInfo.DevicePort, } } //log.Debug("convertDeviceInfoToIotMgr: device: ", device) log.Debug("convertDeviceInfoToIotMgr: device: ", device) return device }
go-packages/meep-iot-mgr/iot-mgr.go +16 −5 Original line number Diff line number Diff line Loading @@ -311,12 +311,13 @@ func (tm *IotMgr) RegisterIotPlatformInfo(iotPlatformInfo IotPlatformInfo) (err log.Info(">>> RegisterIotPlatformInfo: iotPlatformId: ", iotPlatformInfo) if iotPlatformInfo.Enabled { iotPlatformInfo.oneM2M = nil if len(iotPlatformInfo.UserTransportInfo) == 0 || iotPlatformInfo.UserTransportInfo[0].Endpoint == nil || len(iotPlatformInfo.UserTransportInfo[0].Endpoint.Addresses) == 0 { // if len(iotPlatformInfo.UserTransportInfo) == 0 || iotPlatformInfo.UserTransportInfo[0].Endpoint == nil || len(iotPlatformInfo.UserTransportInfo[0].Endpoint.Addresses) == 0 { if len(iotPlatformInfo.CustomServicesTransportInfo) == 0 || iotPlatformInfo.CustomServicesTransportInfo[0].Endpoint == nil || len(iotPlatformInfo.UserTransportInfo[0].Endpoint.Addresses) == 0 { log.Warn("RegisterIotPlatformInfo: Cannot use provided CustomServicesTransportInfo") } else { // FIXME FSCOM How to get the CSE_ID. For the time being, iotPlatformInfo.UserTransportInfo[0].Name is the CSE-resourceID // TODO FSCOM Add notification support? pltf, err := sssmgr.NewSssMgr(tm.name, tm.namespace, iotPlatformInfo.UserTransportInfo[0].Protocol, iotPlatformInfo.UserTransportInfo[0].Endpoint.Addresses[0].Host, int(iotPlatformInfo.UserTransportInfo[0].Endpoint.Addresses[0].Port), iotPlatformInfo.IotPlatformId, iotPlatformInfo.UserTransportInfo[0].Name, nil, nil, nil) pltf, err := sssmgr.NewSssMgr(tm.name, tm.namespace, iotPlatformInfo.CustomServicesTransportInfo[0].Protocol, iotPlatformInfo.CustomServicesTransportInfo[0].Endpoint.Addresses[0].Host, int(iotPlatformInfo.CustomServicesTransportInfo[0].Endpoint.Addresses[0].Port), iotPlatformInfo.IotPlatformId, iotPlatformInfo.CustomServicesTransportInfo[0].Name, nil, nil, nil) if err != nil { log.Error("RegisterIotPlatformInfo: ", err) iotPlatformInfo.oneM2M = nil Loading Loading @@ -422,7 +423,7 @@ func (tm *IotMgr) GetDevices() (devices []DeviceInfo, err error) { return devices, nil } for _, v := range devicesMap { for _, v := range devicesMap { // Process all devices log.Info("GetDevices: adding device: ", v) devices = append(devices, v) } // End of 'for' statement Loading Loading @@ -664,13 +665,23 @@ func (tm *IotMgr) populateDevicesPerIotPlatforms(iotPlatformInfo IotPlatformInfo for _, sensor := range sensors { var deviceInfo = DeviceInfo{ DeviceId: sensor.SensorIdentifier, RequestedIotPlatformId: sensor.IotPlatformId, Enabled: true, } deviceInfo.DeviceMetadata = make([]KeyValuePair, len(sensor.SensorCharacteristicList)) for i, c := range sensor.SensorCharacteristicList { deviceInfo.DeviceMetadata[i] = KeyValuePair{Key: c.CharacteristicName, Value: c.CharacteristicValue} } // End of 'for' statement log.Info("populateDevicesPerIotPlatforms: len(sensor.Flex): ", len(sensor.Flex)) if len(sensor.Flex) != 0 { for k, v := range sensor.Flex { // Process all flex attributes log.Info("populateDevicesPerIotPlatforms: key: ", k) log.Info("populateDevicesPerIotPlatforms: value: ", v) deviceInfo.DeviceMetadata = append(deviceInfo.DeviceMetadata, KeyValuePair{Key: k, Value: v.(string)}) } // End of 'for' statement } log.Info("populateDevicesPerIotPlatforms: add deviceInfo: ", deviceInfo) devicesMap[deviceInfo.DeviceId] = deviceInfo devicesPerPlatformMap[iotPlatformInfo.IotPlatformId] = append(devicesPerPlatformMap[iotPlatformInfo.IotPlatformId], deviceInfo.DeviceId) } // End of 'for' statement Loading
go-packages/meep-sss-mgr/onem2m-mgr.go +5 −4 Original line number Diff line number Diff line Loading @@ -428,7 +428,7 @@ func (tm *SssMgr) populateSensors(iotPlatformInfo IotPlatformInfo, type_ string) } sensorsMap[sensor.SensorIdentifier] = sensor //log.Info("populateSensors: After sensorsMap: ", sensorsMap) //log.Info("populateSensors: Before sensorsPerPlatformMap: ", sensorsPerPlatformMap) log.Info("populateSensors: Before sensorsPerPlatformMap: ", sensorsPerPlatformMap) if len(sensorsPerPlatformMap[sensor.IotPlatformId]) == 0 { sensorsPerPlatformMap[sensor.IotPlatformId] = append(sensorsPerPlatformMap[sensor.IotPlatformId], sensor.SensorIdentifier) } else { // Replace or add a new element Loading @@ -439,13 +439,14 @@ func (tm *SssMgr) populateSensors(iotPlatformInfo IotPlatformInfo, type_ string) break } } // End of 'for' statement log.Info("populateSensors: found idx: ", found) if found != -1 { // Replace sensorsPerPlatformMap[sensor.IotPlatformId] = append(sensorsPerPlatformMap[sensor.IotPlatformId][:found], sensorsPerPlatformMap[sensor.IotPlatformId][found+1:]...) } else { // Add sensorsPerPlatformMap[sensor.IotPlatformId] = append(sensorsPerPlatformMap[sensor.IotPlatformId], sensor.SensorIdentifier) } //log.Info("populateSensors: After sensorsPerPlatformMap: ", sensorsPerPlatformMap) // Add sensorsPerPlatformMap[sensor.IotPlatformId] = append(sensorsPerPlatformMap[sensor.IotPlatformId], sensor.SensorIdentifier) } log.Info("populateSensors: After sensorsPerPlatformMap: ", sensorsPerPlatformMap) } // End of 'for' statement log.Info("populateSensors: sensorsMap: ", sensorsMap) Loading