telefonicaid / sigfox-iotagent

IoT Agent for the Sigfox protocol
https://iotagent-sigfox.rtfd.io/
GNU Affero General Public License v3.0
11 stars 13 forks source link

sigfox-iotagent - Send Measure - DEVICE_NOT_FOUND #27

Open ancappa opened 6 years ago

ancappa commented 6 years ago

Hi, here is the

  1. DEVICE PROVISIONING REQUEST POST /iot/devices Headers: fiware-service: malaga_1 fiware-servicepath: /malaga_1_parking Content-Type: application/json Payload: { "devices": [{ "device_id": "sigApp2", "service" : "malaga_1", "service_path": "/malaga_1_parking", "entity_name": "sigApp2", "entity_type": "Device", "timezone": "America/Santiago", "protocol": "SIGFOX", "attributes": [ { "name": "time", "type": "String" }, { "name": "statin", "type": "String" }, { "name": "lng", "type": "String" }, { "name": "lat", "type": "String" }, { "name": "theCounter", "type": "Integer" }, { "name": "theParam1", "type": "Integer" }, { "name": "param2", "type": "Integer" }, { "name": "tempDegreesCelsius", "type": "Integer" }, { "name": "voltage", "type": "Integer" } ], "lazy": [], "static_attributes": [], "commands": [], "internal_attributes": [ { "mapping": "theCounter::uint:32 theParam1::uint:32 param2::uint:8 tempDegreesCelsius::uint:8 voltage::uint:16" } ] } ] }

  2. SERVICE PROVISIONING REQUEST POST /iot/services/ Headers: fiware-service: malaga_1 fiware-servicepath: /malaga_1_parking Content-Type: application/json Payload: { "services": [ { "cbHost": "xxx.xxx.xxx.xxx:1026", "trust": "xxxxxx", "subservice": "/malaga_1_parking", "service": "malaga_1", "apikey": "XXXX", "resource": "/iot/d", "attributes": [], "lazy": [], "commands": [], "entity_type": "Device", "internal_attributes": [], "static_attributes": [] } ] }

  3. SEND MEASURE Request GET sigfoxHost:sigfoxPort/update?id='sigApp2'&time='1430908992'&statin='0817'&lng=-4&lat=41&data=000000020000000000230c6f Headers: fiware-service: malaga_1 fiware-servicepath: /malaga_1_parking RESPONSE: { "name": "DEVICE_NOT_FOUND", "message": "No device was found with id:'sigApp2'", "code": 404 }

IoTAgent LOG: time=2018-05-14T16:29:05.786Z | lvl=DEBUG | corr=6c0d50c2-f413-41d1-ab60-375a1ad85b01 | trans=6c0d50c2-f413-41d1-ab60-375a1ad85b01 | op=IoTAgentSIGFOX.SigfoxServer | srv=n/a | subsrv=n/a | msg=Request for path [/update] from [sigfoxHost:sigfoxPort] | comp=IoTAgent time=2018-05-14T16:29:05.786Z | lvl=DEBUG | corr=6c0d50c2-f413-41d1-ab60-375a1ad85b01 | trans=6c0d50c2-f413-41d1-ab60-375a1ad85b01 | op=IoTAgentSIGFOX.SigfoxServer | srv=n/a | subsrv=n/a | msg=service: malaga_1 | comp=IoTAgent time=2018-05-14T16:29:05.786Z | lvl=DEBUG | corr=6c0d50c2-f413-41d1-ab60-375a1ad85b01 | trans=6c0d50c2-f413-41d1-ab60-375a1ad85b01 | op=IoTAgentSIGFOX.SigfoxServer | srv=n/a | subsrv=n/a | msg=Unrecognized body type | comp=IoTAgent undefined time=2018-05-14T16:29:05.787Z | lvl=DEBUG | corr=6c0d50c2-f413-41d1-ab60-375a1ad85b01 | trans=6c0d50c2-f413-41d1-ab60-375a1ad85b01 | op=IoTAgentSIGFOX.SigfoxHandlers | srv=n/a | subsrv=n/a | msg=Handling request with query [{"id":"'sigApp2'","time":"'1430908992'","statin":"'0817'","lng":"-4","lat":"41","data":"000000020000000000230c6f"}] | comp=IoTAgent time=2018-05-14T16:29:05.789Z | lvl=DEBUG | corr=6c0d50c2-f413-41d1-ab60-375a1ad85b01 | trans=6c0d50c2-f413-41d1-ab60-375a1ad85b01 | op=IoTAgentNGSI.MongoDBDeviceRegister | srv=n/a | subsrv=n/a | msg=Looking for entity with id ['sigApp2']. | comp=IoTAgent Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html time=2018-05-14T16:29:05.803Z | lvl=DEBUG | corr=6c0d50c2-f413-41d1-ab60-375a1ad85b01 | trans=6c0d50c2-f413-41d1-ab60-375a1ad85b01 | op=IoTAgentNGSI.MongoDBDeviceRegister | srv=n/a | subsrv=n/a | msg=Entity ['sigApp2'] not found. | comp=IoTAgent time=2018-05-14T16:29:05.803Z | lvl=ERROR | corr=6c0d50c2-f413-41d1-ab60-375a1ad85b01 | trans=6c0d50c2-f413-41d1-ab60-375a1ad85b01 | op=IoTAgentNGSI.Alarms | srv=n/a | subsrv=n/a | msg=Raising [MONGO-ALARM]: undefined | comp=IoTAgent

As you can see in the log, the srv=n/a | subsrv=n/a are not available, they have no value , so that the device is not found in the mongo db because the device search has no headers but the device exists in the mongo db.

Thanks in advance for you help.

AlvaroVega commented 6 years ago

Did you configure config.iota.service and config.iota.subservice according that fiware-service and fiware-servicepath in config.js ?

ancappa commented 6 years ago

Hi, yes, in config.js I've configured a default service and subservice, do you mean this configuration? Here the piece of config.js /**

In any case I expect the service and subservice values shall be dynamically read by the request headers fiware-service and fiware-servicepath and not only in the configuration file. Thanks always

ancappa commented 6 years ago

Hi, now I'm using the bin/sigfox-test.js client in order to send measure: SIGFOX Test> sendMeasure 000000020000000000230c6f SIGFOX Test> Data successfully sent

The IoTAgent log is the following: time=2018-05-28T16:18:18.573Z | lvl=DEBUG | corr=4f2a482a-cddc-422a-a8d0-f22782fc89dc | trans=4f2a482a-cddc-422a-a8d0-f22782fc89dc | op=IoTAgentSIGFOX.SigfoxServer | srv=n/a | subsrv=n/a | msg=Request for path [/update] from [localhost:8083] | comp=IoTAgent time=2018-05-28T16:18:18.574Z | lvl=DEBUG | corr=4f2a482a-cddc-422a-a8d0-f22782fc89dc | trans=4f2a482a-cddc-422a-a8d0-f22782fc89dc | op=IoTAgentSIGFOX.SigfoxServer | srv=n/a | subsrv=n/a | msg=Unrecognized body type | comp=IoTAgent undefined time=2018-05-28T16:18:18.575Z | lvl=DEBUG | corr=4f2a482a-cddc-422a-a8d0-f22782fc89dc | trans=4f2a482a-cddc-422a-a8d0-f22782fc89dc | op=IoTAgentSIGFOX.SigfoxHandlers | srv=n/a | subsrv=n/a | msg=Handling request with query [{"id":"sigfox1","time":"1430908992","statin":"0817","lng":"-4","lat":"41","data":"000000020000000000230c6f"}] | comp=IoTAgent time=2018-05-28T16:18:18.577Z | lvl=DEBUG | corr=4f2a482a-cddc-422a-a8d0-f22782fc89dc | trans=4f2a482a-cddc-422a-a8d0-f22782fc89dc | op=IoTAgentNGSI.MongoDBDeviceRegister | srv=n/a | subsrv=n/a | msg=Looking for entity with id [sigfox1]. | comp=IoTAgent Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html time=2018-05-28T16:18:18.593Z | lvl=DEBUG | corr=4f2a482a-cddc-422a-a8d0-f22782fc89dc | trans=4f2a482a-cddc-422a-a8d0-f22782fc89dc | op=IoTAgentNGSI.MongoDBDeviceRegister | srv=n/a | subsrv=n/a | msg=Entity [sigfox1] not found. | comp=IoTAgent

Can you help me sending measure to the IoTAgent Sigfox? Thanks

fgalan commented 5 years ago

@ancappa not sure if it helps, but I'd suggest to try without the single quotes. I mean instead of:

GET sigfoxHost:sigfoxPort/update?id='sigApp2'&time='1430908992'&statin='0817'&lng=-4&lat=41&data=000000020000000000230c6f

try:

GET sigfoxHost:sigfoxPort/update?id=sigApp2&time=1430908992&statin=0817&lng=-4&lat=41&data=000000020000000000230c6f

Looking to the log it seems the query includes the quotes so it doesn't find the device in the DB:

Handling request with query [{"id":"'sigApp2'","time":"'1430908992'","statin":"'0817'","lng":"-4","lat":"41","data":"000000020000000000230c6f"}