Digital Developer Conference: a FREE half-day online conference focused on AI & Cloud – North America: Nov 2 – India: Nov 9 – Europe: Nov 14 – Asia Nov 23 Register now

Close outline
  • United States
IBM?
  • Site map
IBM?
  • Marketplace

  • Close
    Search
  • Sign in
    • Sign in
    • Register
  • IBM Navigation
IBM Developer Answers
  • Spaces
    • Blockchain
    • IBM Cloud platform
    • Internet of Things
    • Predictive Analytics
    • Watson
    • See all spaces
  • Tags
  • Users
  • Badges
  • FAQ
  • Help
Close

Name

Community

  • Learn
  • Develop
  • Connect

Discover IBM

  • ConnectMarketplace
  • Products
  • Services
  • Industries
  • Careers
  • Partners
  • Support
10.190.13.195

Refine your search by using the following advanced search options.

Criteria Usage
Questions with keyword1 or keyword2 keyword1 keyword2
Questions with a mandatory word, e.g. keyword2 keyword1 +keyword2
Questions excluding a word, e.g. keyword2 keyword1 -keyword2
Questions with keyword(s) and a specific tag keyword1 [tag1]
Questions with keyword(s) and either of two or more specific tags keyword1 [tag1] [tag2]
To search for all posts by a user or all posts with a specific tag, start typing and choose from the suggestion list. Do not use a plus or minus sign with a tag, e.g., +[tag1].
  • Ask a question

Publish events to Geospatial Analytics. What am I doing wrong?

2700078N7X gravatar image
Question by migueamat  (3) | Sep 04, 2015 at 02:37 AM iotmqttibmcloudgeospatial

Hi, I am trying to publish MQTT messages from IoT in Geospatial Analytics. I think I am doing everything ok. GA is receiving messages from MQTT, but is not detecting any device in geozone. I have a device registered in my IoT is sending messages with this format:

 {"ts":"2015-09-04T09:23:42.656+0200","d":{"NComb":"59","Speed":"62","Revs":"3168","Temperature":"47","Latitude":"41.380814","FM":"0013","Longitude":"2.183176","idK":"urp3174m8lyr"}}

And I start the GA service with the next code:

 var jsonObject = JSON.stringify({
              "mqtt_client_id_input" : "a:"+ config.your_org + ":geoInput", 
              "mqtt_client_id_notify" : "a:"+ config.your_org + ":geoNotify",
              "mqtt_uid" : config.mqtt.username,
              "mqtt_pw" : config.mqtt.pass,
              "mqtt_uri" :  config.mqtt.host+":"+config.mqtt.port,
              "mqtt_input_topics" : config.subscribeTopic,
              "mqtt_notify_topic" : notify_topic_string,
              "device_id_attr_name" : "idK",
              "latitude_attr_name" : "Latitude",
              "longitude_attr_name" : "Longitude"
          });

Then, I have a quiestion: The "device_id_attr_name" attribute is the name of id attribute in JSON object or is the name of deviceId in IoT?

I think the problem must be in this point.

Thanks in advance.

People who like this

  0
Comment
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

2 answers

  • Sort: 
110000D5G5 gravatar image
Accepted answer

Answer by MikeBranson (643) | Sep 04, 2015 at 04:50 PM

Hello,

To answer the last question that you ask, the "device_id_attr_name" is the name of id attribute in the JSON object. It will be used in the notify messages that get published back to MQTT.

Now on to the main subject of your post. You state that the Geo service is correctly receiving messages from MQTT, but it is not detecting any device-region events. We think that the issue may be with the JSON schema of your MQTT message. "Latitude", "Longitude" and "idK" are not at the top level of your JSON object. They are within a nested object.

Are you able to flatten out your message schema so that the timestamp and the other attributes are all in the top-level object? If so, it would be interesting to see if that eliminates your issue.

Mike B.

Comment

People who like this

  0   Show 1   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
2700078N7X gravatar image migueamat (3)   Sep 15, 2015 at 01:09 AM 0
Share

Hi Mike,

I have been able to put these properties at top level of message, with "ts" and "d" and it is running. Thanks for your answers,

2700078N7X gravatar image

Answer by migueamat (3) | Sep 09, 2015 at 01:31 AM

Then, How Geospatial knows which are the attributes from JSON message that contain latitude, longitude and id to check if device enters in the zone?

Following your indications, now Latitude and Longitude are at top of the message, like this:

 {"ts":"2015-09-09T12:18:23.921+0200","d":{"Latitude":"41.381424","Longitude":"2.18214","idK":"1hbg09corcode","Speed":"11","Temperature":"52","Revs":"3069","NComb":"59","FM":"0009"}}

I imagine you referred to this, because for IoT the message format always is the timestamp and the device attributes in another level inside JSON object.

Regards

Comment

People who like this

  0   Show 4   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
110000D5G5 gravatar image MikeBranson (643)   Sep 09, 2015 at 09:39 AM 0
Share

Sorry if my answer wasn't clear. The order of the attributes is not important. What I was I was suggesting that you move to a message format that looks something like this, e.g.:

 {"ts":"2015-09-09T12:18:23.921+0200","Latitude":"41.381424","Longitude":"2.18214","idK":"1hbg09corcode","Speed":"11","Temperature":"52","Revs":"3069","NComb":"59","FM":"0009"}


In your latest response, the 3 special attributes are still nested inside another JSON object called "d". I was suggesting that you eliminate the nesting, so that the 3 special attributes are at the first level of the JSON object.

2700078N7X gravatar image migueamat (3) MikeBranson (643)   Sep 10, 2015 at 05:36 AM 0
Share

I understood your explanation at first time, but for IoT in Bluemix the JSON object must be with format I show, with the attributes inside object called "d". For this reason I thought the problem could be the fields order. Is there any way to change this format when I send the data to IoT?

Thanks

270003S99K gravatar image Bryan Boyd (116) migueamat (3)   Sep 10, 2015 at 09:54 AM 1
Share

IoT Foundation doesn't explicitly require a "d" top-level property in the JSON payload, however it does encourage this format to allow IoT Foundation to make some assumptions about how data is organized in the payload. If the IoT Foundation payload format is not followed, we refer to this as a "custom payload" in our documentation. IoT Foundation will allow you to publish a custom payload in the format that Mike has suggested:

If you would like to still include the "d" property in your payload, you could duplicate the Latitude and Longitude properties at the top level of the JSON like this:

{"ts":"2015-09-09T12:18:23.921+0200","Latitude":"41.381424","Longitude":"2.18214","d":{"Latitude":"41.381424","Longitude":"2.18214","idK":"1hbg09corcode","Speed":"11","Temperature":"52","Revs":"3069","NComb":"59","FM":"0009"}}

https://docs.internetofthings.ibmcloud.com/messaging/payload.html

Show more comments

Follow this question

74 people are following this question.

Answers

Answers & comments

Related questions

How to integrate Geospatial analytics service with Google map instead of the default map provided? 1 Answer

ANNOUNCEMENT: Geospatial Analytics Service is Now Available 1 Answer

Geospatial Analytics Service: Add Region - Not working Properly - node.js application returning java.lang.ClassCastException 2 Answers

Acces IOTF via MQTT client 2 Answers

IBM Watson IoT Foundation - Device Map 0 Answers

  • Contact
  • Privacy
  • IBM Developer Terms of use
  • Accessibility
  • Report Abuse
  • Cookie Preferences

Powered by AnswerHub

Authentication check. Please ignore.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • API Connect
  • Analytic Hybrid Cloud Core
  • Application Performance Management
  • Appsecdev
  • BPM
  • Blockchain
  • Business Transaction Intelligence
  • CAPI
  • CAPI SNAP
  • CICS
  • Cloud Analytics
  • Cloud Automation
  • Cloud Object Storage
  • Cloud marketplace
  • Collaboration
  • Content Services (ECM)
  • Continuous Testing
  • Courses
  • Customer Experience Analytics
  • DB2 LUW
  • Data and AI
  • DataPower
  • Decision Optimization
  • DevOps Build
  • DevOps Services
  • Developers IBM MX
  • Digital Commerce
  • Digital Experience
  • Finance
  • Global Entrepreneur Program
  • Hadoop
  • Hybrid Cloud Core
  • Hyper Protect
  • IBM Cloud platform
  • IBM Design
  • IBM Forms Experience Builder
  • IBM Maximo Developer
  • IBM StoredIQ
  • IBM StoredIQ-Cartridges
  • IIDR
  • ITOA
  • InformationServer
  • Integration Bus
  • Internet of Things
  • Kenexa
  • Linux on Power
  • LinuxONE
  • MDM
  • Mainframe
  • Messaging
  • Node.js
  • ODM
  • Open
  • PartnerWorld Developer Support
  • PowerAI
  • PowerVC
  • Predictive Analytics
  • Product Insights
  • PureData for Analytics
  • Push
  • QRadar App Development
  • Run Book Automation
  • Search Insights
  • Security Core
  • Storage
  • Storage Core
  • Streamsdev
  • Supply Chain Business Network
  • Supply Chain Insights
  • Swift
  • UBX Capture
  • Universal Behavior Exchange
  • UrbanCode
  • WASdev
  • WSRR
  • Watson
  • Watson Campaign Automation
  • Watson Content Hub
  • Watson Marketing Insights
  • dW Answers Help
  • dW Premium
  • developerWorks Sandbox
  • developerWorks Team
  • Watson Health
  • More
  • Tags
  • Questions
  • Users
  • Badges