• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here: Home » URL Format For Sending Commands Over HTTP (cURL) to IBM Watson IoT

By Abhishek Ghosh September 11, 2019 7:19 am Updated on September 11, 2019

URL Format For Sending Commands Over HTTP (cURL) to IBM Watson IoT

Advertisement

HTTP commands open up wider way to control. This is the corrosponding GitHub repository with a basic example matched with this guide. Already we have shown the serious usages of the method through our Controlling AC Powered Appliances With ESP32 guide. Here is a Discussion on URL Format or Sending Commands Over HTTP (cURL) to IBM Watson IoT.

IBM’s platform is configured to accept events from the device and commands from an application i.e. the cURL command over HTTP. We need different headers for authentication. The devices authenticate with user-token-auth and the device’s token. But the applications authenticate with API keys. Here is documentation on IBM’s website.

Look at the code on GitHub. Notice the below lines :

Advertisement

---

Vim
1
2
3
4
5
…
#define CMD_STATE "/gpio/"
 
const char commandTopic[] = "iot-2/cmd/+/fmt/+";
…

URL Format or Sending Commands Over HTTP cURL to IBM Watson IoT

When we run this command the LED becomes ON :

Vim
1
curl -u <use-the-API-Key>:<use-auth-token> -H "Content-Type: text/plain" -v -X POST http://<your org>.messaging.internetofthings.ibmcloud.com:1883/api/v0002/application/types/<yourDeviceType>/devices/<yourDeviceId>/commands/gpio -d "on"

When we run this command the LED becomes OFF :

Vim
1
curl -u <use-the-API-Key>:<use-auth-token> -H "Content-Type: text/plain" -v -X POST http://<your org>.messaging.internetofthings.ibmcloud.com:1883/api/v0002/application/types/<yourDeviceType>/devices/<yourDeviceId>/commands/gpio -d "off"

Our command URL is this :

Vim
1
http://<your org>.messaging.internetofthings.ibmcloud.com:1883/api/v0002/application/types/<yourDeviceType>/devices/<yourDeviceId>/commands/gpio

We can not alter this format much as that will not match IBM’s server configuration. You can change the phrase gpio to something like led to test – that will work when you change the #define CMD_STATE "/gpio/" line to #define CMD_STATE "/led/". IBM’s configuration supports nomenclature such as gpio1, led1 and so on. That is a helpful trick to add multiple things.

The second part you need to know is about this line :

Vim
1
const char commandTopic[] = "iot-2/cmd/+/fmt/+";

I used + as a wildcard in two places – the + between /cmd/ and /fmt/ could be changed to gpio for the above example code.

You can change it the code to something like the below :

Vim
1
2
const char commandTopic1[] = "iot-2/cmd/led/fmt/+";
const char commandTopic2[] = "iot-2/cmd/led1/fmt/+";

So, in your code if you decide to change the end of the command to fool, you should change two lines on code :

Vim
1
2
3
#define CMD_STATE "/fool/"
 
const char commandTopic[] = "iot-2/cmd/fool/fmt/+";

The command to make it working will be :

Vim
1
http://<your org>.messaging.internetofthings.ibmcloud.com:1883/api/v0002/application/types/<yourDeviceType>/devices/<yourDeviceId>/commands/fool

So, you are changing 3 things to rename a thing :

1. The #define CMD_STATE line
2. The const char commandTopic[] line
3. End of the URL to send cURL command i.e. ../devices//commands/gpio

We already know that we can use an Android app to create button and send the cURL requests to switch on and switch off the LED.

This ends this guide. Our next chapters will be connecting it to Node-RED to create a web toggle button.

Tagged With how to send a curl command to an iot device

This Article Has Been Shared 600 Times!

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to URL Format For Sending Commands Over HTTP (cURL) to IBM Watson IoT

  • How to Connect Apache Kafka With MQTT

    We Can Connect Apache Kafka With MQTT in Different Ways With Different Types of Available Connectors, Including Connectors Based on REST API.

  • Install Nginx HTTP/2 With ALPN on Ubuntu 14.04 From ondrej/nginx PPA

    In our previous guide, we have shown how to easily upgrade Nginx on Ubuntu 14.04 for HTTP/2 support. The required changes in the /etc/nginx/sites-enabled/default file, /etc/nginx/nginx.conf file and limitations of that way of installation has been discussed on this article. In this guide, we will show how to install Nginx HTTP/2 with ALPN on Ubuntu […]

  • Configure Apache With Fail2Ban on Ubuntu 18.04

    Here is How To Configure Apache With Fail2Ban on Ubuntu 18.04 to block more types of malicious attempts towards server to create a practical firewall.

  • Internet of Things in the Smart Home : Part II

    The devices in the smart home act independently, networked or both. Intelligence is intended to expand functions or introduce new functions into the already known devices, thus creating added value for the user.

  • How To Install Apache Phoenix (SQL on HBase)

    We talked about Apache Phoenix in our previous guides and articles such as How To Install Apache HBase and List of Apache Projects For Big Data. Apache Phoenix is a massively parallel, relational database engine supporting OLTP for Hadoop using Apache HBase as store. Phoenix provides a JDBC driver that cleverly hides the noSQL store […]

Additionally, performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • What is Voice User Interface (VUI) January 31, 2023
  • Proxy Server: Design Pattern in Programming January 30, 2023
  • Cyberpunk Aesthetics: What’s in it Special January 27, 2023
  • How to Do Electrical Layout Plan for Adding Smart Switches January 26, 2023
  • What is a Data Mesh? January 25, 2023

About This Article

Cite this article as: Abhishek Ghosh, "URL Format For Sending Commands Over HTTP (cURL) to IBM Watson IoT," in The Customize Windows, September 11, 2019, January 31, 2023, https://thecustomizewindows.com/2019/09/url-format-or-sending-commands-over-http-curl-to-ibm-watson-iot/.

Source:The Customize Windows, JiMA.in

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT