NOISSUE - Add LoRa route map validation and fix LoRa messages URL (#491)

* Add route map validation and fix LoRa messages URL

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Fix reviews

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Fix reviews

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Rm private error comments

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Fix typo

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Add runlora command in Makefile

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
This commit is contained in:
Manuel Imperiale 2018-12-05 15:15:15 +01:00 committed by Drasko DRASKOVIC
parent b9bf63e377
commit 715a662f0d
4 changed files with 32 additions and 7 deletions

View File

@ -96,3 +96,8 @@ rundev:
run:
docker-compose -f docker/docker-compose.yml up
runlora:
docker-compose -f docker/docker-compose.yml up -d
docker-compose -f docker/addons/influxdb-writer/docker-compose.yml up -d
docker-compose -f docker/addons/lora-adapter/docker-compose.yml up

View File

@ -27,7 +27,7 @@ services:
MF_LORA_ADAPTER_LOG_LEVEL: debug
MF_THINGS_ES_URL: things-redis:6379
MF_LORA_ADAPTER_ROUTEMAP_URL: lora-redis:6379
MF_LORA_ADAPTER_LORA_MESSAGE_URL: tcp://159.65.205.240:1883
MF_LORA_ADAPTER_LORA_MESSAGE_URL: tcp://lora.mqtt.mainflux.io:1883
MF_LORA_ADAPTER_HTTP_PORT: 8187
MF_NATS_URL: nats://nats:4222
ports:

View File

@ -27,6 +27,14 @@ const (
channelRemove = channelPrefix + "remove"
)
var (
errMetadataType = errors.New("metadatada is not of type lora")
errMetadataAppID = errors.New("application ID not found in channel metadatada")
errMetadataDevEUI = errors.New("device EUI not found in thing metadatada")
)
// EventStore represents event source for things and channels provisioning.
type EventStore interface {
// Subscribes to geven subject and receives events.
@ -155,7 +163,10 @@ func (es eventStore) handleCreateThing(cte createThingEvent) error {
}
if em.Type != protocol {
return errors.New("Lora protocol not found in thing metadatada")
return errMetadataType
}
if em.DevEUI != "" {
return errMetadataDevEUI
}
return es.svc.CreateThing(cte.id, em.DevEUI)
@ -168,7 +179,10 @@ func (es eventStore) handleUpdateThing(ute updateThingEvent) error {
}
if em.Type != protocol {
return errors.New("Lora protocol not found in thing metadatada")
return errMetadataType
}
if em.DevEUI != "" {
return errMetadataDevEUI
}
return es.svc.CreateThing(ute.id, em.DevEUI)
@ -185,7 +199,10 @@ func (es eventStore) handleCreateChannel(cce createChannelEvent) error {
}
if cm.Type != protocol {
return errors.New("Lora protocol not found in channel metadatada")
return errMetadataType
}
if cm.AppID != "" {
return errMetadataAppID
}
return es.svc.CreateChannel(cce.id, cm.AppID)
@ -198,7 +215,10 @@ func (es eventStore) handleUpdateChannel(uce updateChannelEvent) error {
}
if cm.Type != protocol {
return errors.New("Lora protocol not found in channel metadatada")
return errMetadataType
}
if cm.AppID != "" {
return errMetadataAppID
}
return es.svc.UpdateChannel(uce.id, cm.AppID)

View File

@ -22,10 +22,10 @@ var (
ErrMalformedMessage = errors.New("malformed message received")
// ErrNotFoundDev indicates a non-existent route map for a device EUI.
ErrNotFoundDev = errors.New("route map not found for device EUI")
ErrNotFoundDev = errors.New("route map not found for this device EUI")
// ErrNotFoundApp indicates a non-existent route map for an application ID.
ErrNotFoundApp = errors.New("route map not found for application ID")
ErrNotFoundApp = errors.New("route map not found for this application ID")
)
// Service specifies an API that must be fullfiled by the domain service