• 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 844 Times!

Facebook Twitter Pinterest
Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Orthopaedic 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

You can subscribe to our Free Once a Day, Regular Newsletter by clicking the subscribe button below.

Click To Subscribe

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 (21K Followers)
  • Twitter (5.3k 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

  • Best Powerpoint Templates for Communicating IoT Concepts April 17, 2021
  • How to Build a DIY Water Level Indicator? April 16, 2021
  • How Startups Can Convince the Investors April 14, 2021
  • What to Know About the Cloud Storage Services for Smartphones April 13, 2021
  • WonderFox HD Video Converter Factory Pro Review April 10, 2021

 

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, April 19, 2021, https://thecustomizewindows.com/2019/09/url-format-or-sending-commands-over-http-curl-to-ibm-watson-iot/.

Source:The Customize Windows, JiMA.in

 

This website uses cookies. If you do not want to allow us to use cookies and/or non-personalized Ads, kindly clear browser cookies after closing this webpage.

Read Cookie Policy.

PC users can consult Corrine Chorney for Security.

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

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

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