To use c programming

Dear sir/madam,
I am writing this forum to request you to send steps to be followed to control bolt wifi module using C programming language.I learnt C programming as part of course in my college.So I don’t want to waste my time in learning other programming languages.
In light of above situation i would request you to send steps to be followed at your earliest convinience.
Thank you.
yours sincerely,
Akhilesh.

Hello
Familiarize yourself with the Bolt Cloud API documentation provided by the Bolt IoT platform.Ensure you have a C development environment set up on your computer ,for example visual studio code.You will need a library to make HTTP/HTTPS requests in C. For example, you can use a libcurl .Process the responses received from the Bolt Cloud API. This may involve parsing JSON data if the API response is in JSON format.These are the basic requirements for using bolt wifi module.Also u can use any virtualisation softwares like VMware. Just setup ur bolt wifi module and start using it .U can refer this link for further information https://docs.boltiot.com/docs .

Hi @me23btech11058 ,

Apologies for the delayed response. Here is a simple C code to control led using bolt wi-fi module. (Replace “YOUR API KEY” with the actual API key and Device id with the actual device ID of the Bolt device.

#include <curl/curl.h>
#include <stdio.h>
#include <stdlib.h> // Include this for EXIT_SUCCESS and EXIT_FAILURE

#define API_KEY "YOUR_API_KEY"
#define DEVICE_ID "BOLTXXXXXX"

// Function to send HTTP request to control the LED
CURLcode sendRequest(const char *url) {
  CURL *curl;
  CURLcode res;

  curl_global_init(CURL_GLOBAL_DEFAULT);

  curl = curl_easy_init();
  if (curl) {
    curl_easy_setopt(curl, CURLOPT_URL, url);
    res = curl_easy_perform(curl);

    if (res != CURLE_OK) {
      fprintf(stderr, "curl_easy_perform() failed: %s\n",
              curl_easy_strerror(res));
    }

    curl_easy_cleanup(curl);
  }

  curl_global_cleanup();

  return res;
}

int main() {
  // Set the URL for the digital write API endpoint
  const char *url =
      "https://cloud.boltiot.com/remote/YOUR API KEY/"
      "digitalWrite?deviceName=BOLTXXXXX&pin=0&state=HIGH";

  // Send the HTTP request to control the LED
  CURLcode response = sendRequest(url);

  if (response != CURLE_OK) {
    fprintf(stderr, "Failed to control LED. Error code: %d\n", response);
    return 1; // Return 1 for failure
  }

  printf("LED controlled successfully.\n");

  return 0; // Return 0 for success
}

Make sure to install curl library. Run below command in shell to install curl library:

sudo apt-get install libcurl4-openssl-dev

Finally, compile and run your c file. Please run the following commands(Replace “your_filename” with the actual name of the c file:

gcc your_filename.c -o your_filename -lcurl
gcc your_filename.c -o your_filename -L/path/to/libcurl -lcurl

Run your program:

./your_filename

After following these steps the led should be switched ON.

If you face any issues feel free to get back to us.