AlertWear-T20 Developer's Portal

Introduction

 

Black Box launches BLE tags, wearable devices and asset trackers based on BLE beacon based IOT technology. These robust and rugged AlertWear tags and Asset Tracker devices comes with replaceable batteries.

State of the art technology from Black Box enables you to locate people and assets in real time. In addition, condition monitoring for the Industry 4.0 is one of the most important use cases for the AlertWear beacons, designed, developed and manufactured at Black Box.

 

Protocol Doc

 

AlertWear T20 FW 5.0
Beacon Protocols

View Protocol Doc

AlertWear T20 FW 5.1
Beacon Temperature Protocols

View Protocol Doc

AlertWear T20 FW 5.1.1
Beacon Temperature With Memory Protocols

View Protocol Doc

AlertWear T20 FW 5.2
Beacon Temperature Humidity Protocols

View Protocol Doc

Authentication

 

To get started using AlertWear's API platform, you'll need a valid API key. All authenticated API requests should have a header token. The API token can be generated by using API user’s credentials (i.e. Valid API Username & Password). If you're a current customer and don't have an API user’s credentials, please contact support. A sample snippet of the code across various platforms are given below:

 

    curl "http://doguz.io/t20/index.php/api/datasync/login" \
    -X POST \
    -d "username=admin&password=***" \
    -H "Content-Type: application/x-www-form-urlencoded"
    POST /t20/index.php/api/datasync/login HTTP/1.1
    Host: doguz.io:80
    Content-Type: application/x-www-form-urlencoded
    username=admin&password=***
    const headers = new Headers();
    headers.append('Content-Type', 'application/x-www-form-urlencoded');

    const body = `username=admin&password=***`;

    const init = {
      method: 'POST',
      headers,
      body
    };

    fetch('http://doguz.io/t20/index.php/api/datasync/login', init)
    .then((response) => {
      return response.json(); // or .text() or .blob() ...
    })
    .then((text) => {
      // text is the response body
    })
    .catch((e) => {
      // error in e.message
    });
    (async () => {
      const headers = new Headers();
      headers.append('Content-Type', 'application/x-www-form-urlencoded');

      const body = `username=admin&password=***`;

      const init = {
        method: 'POST',
        headers,
        body
      };

      const response = await fetch('http://doguz.io/t20/index.php/api/datasync/login', init);
      console.log(`response status is ${response.status}`);
      const mediaType = response.headers.get('content-type');
      let data;
      if (mediaType.includes('json')) {
        data = await response.json();
      } else {
        data = await response.text();
      }
      console.log(data);
    })();
    const http = require('http');
    const init = {
      host: 'doguz.io',
      path: '/t20/index.php/api/datasync/login',
      method: 'POST',
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    };
    const callback = function(response) {
      let result = Buffer.alloc(0);
      response.on('data', function(chunk) {
        result = Buffer.concat([result, chunk]);
      });
      
      response.on('end', function() {
        // result has response body buffer
        console.log(result.toString());
      });
    };

    const req = http.request(init, callback);
    const body = `username=admin&password=***`;
    req.write(body);
    req.end();

    var xhr = new XMLHttpRequest();
    xhr.addEventListener('load', function(e) {
      var response = e.target.responseText;
      console.log(response);
    });
    xhr.addEventListener('error', function(e) {
      console.error('Request errored with status', e.target.status);
    });
    xhr.open('POST', 'http://doguz.io/t20/index.php/api/datasync/login');
    xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    var body = '';
    body += 'username=admin&password=***';
    xhr.send(body);

    import requests

    url = 'http://doguz.io/t20/index.php/api/datasync/login'
    headers = {'Content-Type': 'application/x-www-form-urlencoded'}
    body = """username=admin&password=***"""

    req = requests.post(url, headers=headers, data=body)

    print(req.status_code)
    print(req.headers)
    print(req.text)
    import httplib

    headers = {'Content-Type': 'application/x-www-form-urlencoded'}
    body = """username=admin&password=***"""

    conn = httplib.HTTPConnection('doguz.io')
    conn.request('POST','/t20/index.php/api/datasync/login', body, headers)
    res = conn.getresponse()

    print(res.status, res.reason)
    print(res.read())
    print(res.getheaders())
    import http.client

    headers = {'Content-Type': 'application/x-www-form-urlencoded'}
    body = """username=admin&password=***"""

    conn = http.client.HTTPConnection('doguz.io')
    conn.request('POST','/t20/index.php/api/datasync/login', body, headers)
    res = conn.getresponse()

    data = res.read()
    print(res.status, res.reason)
    print(data.decode('utf-8'))
    print(res.getheaders())
    var xhr = new XMLHttpRequest();
    xhr.addEventListener('load', function(e) {
      var response = e.target.responseText;
      console.log(response);
    });
    xhr.addEventListener('error', function(e) {
      console.error('Request errored with status', e.target.status);
    });
    xhr.open('POST', 'http://182.18.139.139/jido/index.php/api/datasync/login');
    xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    var body = '';
    body += 'username=admin&password=***';
    xhr.send(body);
    #include 
    #include 

    int main(void)
    {
        CURL *curl;
        CURLcode res;

        curl = curl_easy_init();
        curl_easy_setopt(curl, CURLOPT_URL, "http://doguz.io/t20/index.php/api/datasync/login");
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
        /* if redirected, tell libcurl to follow redirection */
        curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);

        struct curl_slist *headers = NULL;
        headers = curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

        char *body ="username=admin&password=***";
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body);

        /* Perform the request, res will get the return code */
        res = curl_easy_perform(curl);
        if (res != CURLE_OK) {
            fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
        }
        /* Clean up after yourself */
        curl_easy_cleanup(curl);
        return 0;
    }
    /* See: http://stackoverflow.com/a/2329792/1127848 of how to read data from the response. */
    URL url = new URL("http://doguz.io/t20/index.php/api/datasync/login");
    HttpURLConnection con = (HttpURLConnection) url.openConnection();
    con.setRequestMethod("POST");
    con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

    /* Payload support */
    con.setDoOutput(true);
    DataOutputStream out = new DataOutputStream(con.getOutputStream());
    out.writeBytes("username=admin&password=***");
    out.flush();
    out.close();

    int status = con.getResponseCode();
    BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
    String inputLine;
    StringBuffer content = new StringBuffer();
    while((inputLine = in.readLine()) != null) {
        content.append(inputLine);
    }
    in.close();
    con.disconnect();
    System.out.println("Response status: " + status);
    System.out.println(content.toString());
    RestTemplate rest = new RestTemplate();
    HttpHeaders headers = new HttpHeaders();
    headers.add("Content-Type", "application/x-www-form-urlencoded");

    StringBuilder sb = new StringBuilder();
    sb.append("username=admin&password=***");
    String body = sb.toString();

    HttpEntity requestEntity = new HttpEntity(body, headers);
    ResponseEntity responseEntity = rest.exchange("http://doguz.io/t20/index.php/api/datasync/login", HttpMethod.POST, requestEntity, String.class);
    HttpStatus httpStatus = responseEntity.getStatusCode();
    int status = httpStatus.value();
    String response = responseEntity.getBody();
    System.out.println("Response status: " + status);
    System.out.println(response);

Device Configuration

 

To get the latest device configuration, you’ll need to pass the corresponding object’s 'organization ID' and ‘Authenticated token’ as API request parameters. API will return the latest configuration that will be updated on the assigned devices. A sample snippet of the code across various platforms are given below:

 

    curl "http://doguz.io/t20/index.php/api/datasync/getdeviceconfigdata" \
      -X POST \
      -d "token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&asigned_to_id=6" \
      -H "Content-Type: application/x-www-form-urlencoded" 
    POST /t20/index.php/api/datasync/getdeviceconfigdata HTTP/1.1
    Host: doguz.io:80
    Content-Type: application/x-www-form-urlencoded

    token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&asigned_to_id=6
    const headers = new Headers();
    headers.append('Content-Type', 'application/x-www-form-urlencoded');

    const body = `token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&asigned_to_id=6`;

    const init = {
      method: 'POST',
      headers,
      body
    };

    fetch('http://doguz.io/t20/index.php/api/datasync/getdeviceconfigdata', init)
    .then((response) => {
      return response.json(); // or .text() or .blob() ...
    })
    .then((text) => {
      // text is the response body
    })
    .catch((e) => {
      // error in e.message
    });
    (async () => {
      const headers = new Headers();
      headers.append('Content-Type', 'application/x-www-form-urlencoded');

      const body = `token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&asigned_to_id=6`;

      const init = {
        method: 'POST',
        headers,
        body
      };

      const response = await fetch('http://doguz.io/t20/index.php/api/datasync/getdeviceconfigdata', init);
      console.log(`response status is ${response.status}`);
      const mediaType = response.headers.get('content-type');
      let data;
      if (mediaType.includes('json')) {
        data = await response.json();
      } else {
        data = await response.text();
      }
      console.log(data);
    })();
    const http = require('http');
    const init = {
      host: 'doguz.io',
      path: '/t20/index.php/api/datasync/getdeviceconfigdata',
      method: 'POST',
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    };
    const callback = function(response) {
      let result = Buffer.alloc(0);
      response.on('data', function(chunk) {
        result = Buffer.concat([result, chunk]);
      });
      
      response.on('end', function() {
        // result has response body buffer
        console.log(result.toString());
      });
    };

    const req = http.request(init, callback);
    const body = `token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&asigned_to_id=6`;
    req.write(body);
    req.end();
    var xhr = new XMLHttpRequest();
    xhr.addEventListener('load', function(e) {
      var response = e.target.responseText;
      console.log(response);
    });
    xhr.addEventListener('error', function(e) {
      console.error('Request errored with status', e.target.status);
    });
    xhr.open('POST', 'http://doguz.io/t20/index.php/api/datasync/getdeviceconfigdata');
    xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    var body = '';
    body += 'token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&asigned_to_id=6';
    xhr.send(body);

    import requests

    url = 'http://doguz.io/t20/index.php/api/datasync/getdeviceconfigdata'
    headers = {'Content-Type': 'application/x-www-form-urlencoded'}
    body = """token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&asigned_to_id=6"""

    req = requests.post(url, headers=headers, data=body)

    print(req.status_code)
    print(req.headers)
    print(req.text)
    import httplib

    headers = {'Content-Type': 'application/x-www-form-urlencoded'}
    body = """token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&asigned_to_id=6"""

    conn = httplib.HTTPConnection('doguz.io')
    conn.request('POST','/t20/index.php/api/datasync/getdeviceconfigdata', body, headers)
    res = conn.getresponse()

    print(res.status, res.reason)
    print(res.read())
    print(res.getheaders())
    import http.client

    headers = {'Content-Type': 'application/x-www-form-urlencoded'}
    body = """token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&asigned_to_id=6"""

    conn = http.client.HTTPConnection('doguz.io')
    conn.request('POST','/t20/index.php/api/datasync/getdeviceconfigdata', body, headers)
    res = conn.getresponse()

    data = res.read()
    print(res.status, res.reason)
    print(data.decode('utf-8'))
    print(res.getheaders())
    #include 
    #include 

    int main(void)
    {
        CURL *curl;
        CURLcode res;

        curl = curl_easy_init();
        curl_easy_setopt(curl, CURLOPT_URL, "http://doguz.io/t20/index.php/api/datasync/getdeviceconfigdata");
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
        /* if redirected, tell libcurl to follow redirection */
        curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);

        struct curl_slist *headers = NULL;
        headers = curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

        char *body ="token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&asigned_to_id=6";
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body);

        /* Perform the request, res will get the return code */
        res = curl_easy_perform(curl);
        if (res != CURLE_OK) {
            fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
        }
        /* Clean up after yourself */
        curl_easy_cleanup(curl);
        return 0;
    }
    /* See: http://stackoverflow.com/a/2329792/1127848 of how to read data from the response. */
    URL url = new URL("http://doguz.io/t20/index.php/api/datasync/getdeviceconfigdata");
    HttpURLConnection con = (HttpURLConnection) url.openConnection();
    con.setRequestMethod("POST");
    con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

    /* Payload support */
    con.setDoOutput(true);
    DataOutputStream out = new DataOutputStream(con.getOutputStream());
    out.writeBytes("token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&asigned_to_id=6");
    out.flush();
    out.close();

    int status = con.getResponseCode();
    BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
    String inputLine;
    StringBuffer content = new StringBuffer();
    while((inputLine = in.readLine()) != null) {
        content.append(inputLine);
    }
    in.close();
    con.disconnect();
    System.out.println("Response status: " + status);
    System.out.println(content.toString());
    RestTemplate rest = new RestTemplate();
    HttpHeaders headers = new HttpHeaders();
    headers.add("Content-Type", "application/x-www-form-urlencoded");

    StringBuilder sb = new StringBuilder();
    sb.append("token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&asigned_to_id=6");
    String body = sb.toString();

    HttpEntity requestEntity = new HttpEntity(body, headers);
    ResponseEntity responseEntity = rest.exchange("http://doguz.io/t20/index.php/api/datasync/getdeviceconfigdata", HttpMethod.POST, requestEntity, String.class);
    HttpStatus httpStatus = responseEntity.getStatusCode();
    int status = httpStatus.value();
    String response = responseEntity.getBody();
    System.out.println("Response status: " + status);
    System.out.println(response);

After Firmware Updates

 

Once the firmware gets updated on the device, it sends an acknowledgment to the server. It tracks which device's parameters have been updated.You’ll need to pass the corresponding object’s 'data' and ‘Authenticated token’ as API request parameters. API will return a success or failure message based on the server-side operations. A sample snippet of the code across various platforms are given below:

 

    curl "http://doguz.io/t20/index.php/api/datasync/afterdeviceconfig" \
      -X POST \
      -d "token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&data={\"mac_id\":\"84:71:27:21:84:71\",\"ble_uuid\":\"12343800-203b-2f02-0000-000000120000\",\"ble_uuid_YN\":\"N\",\"major\":\"168\",\"major_YN\":\"N\",\"minor\":\"2\",\"minor_YN\":\"N\",\"transmission_interval\":\"100\",\"transmission_interval_YN\":\"N\",\"working_hour_st_time\":\"0\",\"working_hour_st_time_YN\":\"N\",\"working_hour_end_time\":\"23\",\"working_hour_end_time_YN\":\"N\",\"device_name\":\"Black Box\",\"device_name_YN\":\"N\",\"tx_power\":\"-1\",\"tx_power_YN\":\"N\",\"temp_mem_record_interval\":\"\",\"temp_mem_record_interval_YN\":\"N\",\"fw_ver\":\"5.0\",\"updt_time\":\"1620748663390\",\"insertby\":\"1\"}" \
      -H "Content-Type: application/x-www-form-urlencoded" 
    POST /t20/index.php/api/datasync/afterdeviceconfig HTTP/1.1
    Host: doguz.io:80
    Content-Type: application/x-www-form-urlencoded

    token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&data={"mac_id":"84:71:27:21:84:71","ble_uuid":"12343800-203b-2f02-0000-000000120000","ble_uuid_YN":"N","major":"168","major_YN":"N","minor":"2","minor_YN":"N","transmission_interval":"100","transmission_interval_YN":"N","working_hour_st_time":"0","working_hour_st_time_YN":"N","working_hour_end_time":"23","working_hour_end_time_YN":"N","device_name":"Black Box","device_name_YN":"N","tx_power":"-1","tx_power_YN":"N","temp_mem_record_interval":"","temp_mem_record_interval_YN":"N","fw_ver":"5.0","updt_time":"1620748663390","insertby":"1"}


    const headers = new Headers();
    headers.append('Content-Type', 'application/x-www-form-urlencoded');

    const body = `token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&data={"mac_id":"84:71:27:21:84:71","ble_uuid":"12343800-203b-2f02-0000-000000120000","ble_uuid_YN":"N","major":"168","major_YN":"N","minor":"2","minor_YN":"N","transmission_interval":"100","transmission_interval_YN":"N","working_hour_st_time":"0","working_hour_st_time_YN":"N","working_hour_end_time":"23","working_hour_end_time_YN":"N","device_name":"Black Box","device_name_YN":"N","tx_power":"-1","tx_power_YN":"N","temp_mem_record_interval":"","temp_mem_record_interval_YN":"N","fw_ver":"5.0","updt_time":"1620748663390","insertby":"1"}`;

    const init = {
      method: 'POST',
      headers,
      body
    };

    fetch('http://doguz.io/t20/index.php/api/datasync/afterdeviceconfig', init)
    .then((response) => {
      return response.json(); // or .text() or .blob() ...
    })
    .then((text) => {
      // text is the response body
    })
    .catch((e) => {
      // error in e.message
    });
    (async () => {
      const headers = new Headers();
      headers.append('Content-Type', 'application/x-www-form-urlencoded');

      const body = `token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&data={"mac_id":"84:71:27:21:84:71","ble_uuid":"12343800-203b-2f02-0000-000000120000","ble_uuid_YN":"N","major":"168","major_YN":"N","minor":"2","minor_YN":"N","transmission_interval":"100","transmission_interval_YN":"N","working_hour_st_time":"0","working_hour_st_time_YN":"N","working_hour_end_time":"23","working_hour_end_time_YN":"N","device_name":"Black Box","device_name_YN":"N","tx_power":"-1","tx_power_YN":"N","temp_mem_record_interval":"","temp_mem_record_interval_YN":"N","fw_ver":"5.0","updt_time":"1620748663390","insertby":"1"}`;

      const init = {
        method: 'POST',
        headers,
        body
      };

      const response = await fetch('http://doguz.io/t20/index.php/api/datasync/afterdeviceconfig', init);
      console.log(`response status is ${response.status}`);
      const mediaType = response.headers.get('content-type');
      let data;
      if (mediaType.includes('json')) {
        data = await response.json();
      } else {
        data = await response.text();
      }
      console.log(data);
    })();
    const http = require('http');
    const init = {
      host: 'doguz.io',
      path: '/t20/index.php/api/datasync/afterdeviceconfig',
      method: 'POST',
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    };
    const callback = function(response) {
      let result = Buffer.alloc(0);
      response.on('data', function(chunk) {
        result = Buffer.concat([result, chunk]);
      });
      
      response.on('end', function() {
        // result has response body buffer
        console.log(result.toString());
      });
    };

    const req = http.request(init, callback);
    const body = `token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&data={"mac_id":"84:71:27:21:84:71","ble_uuid":"12343800-203b-2f02-0000-000000120000","ble_uuid_YN":"N","major":"168","major_YN":"N","minor":"2","minor_YN":"N","transmission_interval":"100","transmission_interval_YN":"N","working_hour_st_time":"0","working_hour_st_time_YN":"N","working_hour_end_time":"23","working_hour_end_time_YN":"N","device_name":"Black Box","device_name_YN":"N","tx_power":"-1","tx_power_YN":"N","temp_mem_record_interval":"","temp_mem_record_interval_YN":"N","fw_ver":"5.0","updt_time":"1620748663390","insertby":"1"}`;
    req.write(body);
    req.end();
    var xhr = new XMLHttpRequest();
    xhr.addEventListener('load', function(e) {
      var response = e.target.responseText;
      console.log(response);
    });
    xhr.addEventListener('error', function(e) {
      console.error('Request errored with status', e.target.status);
    });
    xhr.open('POST', 'http://doguz.io/t20/index.php/api/datasync/afterdeviceconfig');
    xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    var body = '';
    body += 'token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&data={"mac_id":"84:71:27:21:84:71","ble_uuid":"12343800-203b-2f02-0000-000000120000","ble_uuid_YN":"N","major":"168","major_YN":"N","minor":"2","minor_YN":"N","transmission_interval":"100","transmission_interval_YN":"N","working_hour_st_time":"0","working_hour_st_time_YN":"N","working_hour_end_time":"23","working_hour_end_time_YN":"N","device_name":"Black Box","device_name_YN":"N","tx_power":"-1","tx_power_YN":"N","temp_mem_record_interval":"","temp_mem_record_interval_YN":"N","fw_ver":"5.0","updt_time":"1620748663390","insertby":"1"}';
    xhr.send(body);
    import requests

    url = 'http://doguz.io/t20/index.php/api/datasync/afterdeviceconfig'
    headers = {'Content-Type': 'application/x-www-form-urlencoded'}
    body = """token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&data={"mac_id":"84:71:27:21:84:71","ble_uuid":"12343800-203b-2f02-0000-000000120000","ble_uuid_YN":"N","major":"168","major_YN":"N","minor":"2","minor_YN":"N","transmission_interval":"100","transmission_interval_YN":"N","working_hour_st_time":"0","working_hour_st_time_YN":"N","working_hour_end_time":"23","working_hour_end_time_YN":"N","device_name":"Black Box","device_name_YN":"N","tx_power":"-1","tx_power_YN":"N","temp_mem_record_interval":"","temp_mem_record_interval_YN":"N","fw_ver":"5.0","updt_time":"1620748663390","insertby":"1"}"""

    req = requests.post(url, headers=headers, data=body)

    print(req.status_code)
    print(req.headers)
    print(req.text)
    import httplib

    headers = {'Content-Type': 'application/x-www-form-urlencoded'}
    body = """token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&data={"mac_id":"84:71:27:21:84:71","ble_uuid":"12343800-203b-2f02-0000-000000120000","ble_uuid_YN":"N","major":"168","major_YN":"N","minor":"2","minor_YN":"N","transmission_interval":"100","transmission_interval_YN":"N","working_hour_st_time":"0","working_hour_st_time_YN":"N","working_hour_end_time":"23","working_hour_end_time_YN":"N","device_name":"Black Box","device_name_YN":"N","tx_power":"-1","tx_power_YN":"N","temp_mem_record_interval":"","temp_mem_record_interval_YN":"N","fw_ver":"5.0","updt_time":"1620748663390","insertby":"1"}"""

    conn = httplib.HTTPConnection('doguz.io')
    conn.request('POST','/t20/index.php/api/datasync/afterdeviceconfig', body, headers)
    res = conn.getresponse()

    print(res.status, res.reason)
    print(res.read())
    print(res.getheaders())
    import http.client

    headers = {'Content-Type': 'application/x-www-form-urlencoded'}
    body = """token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&data={"mac_id":"84:71:27:21:84:71","ble_uuid":"12343800-203b-2f02-0000-000000120000","ble_uuid_YN":"N","major":"168","major_YN":"N","minor":"2","minor_YN":"N","transmission_interval":"100","transmission_interval_YN":"N","working_hour_st_time":"0","working_hour_st_time_YN":"N","working_hour_end_time":"23","working_hour_end_time_YN":"N","device_name":"Black Box","device_name_YN":"N","tx_power":"-1","tx_power_YN":"N","temp_mem_record_interval":"","temp_mem_record_interval_YN":"N","fw_ver":"5.0","updt_time":"1620748663390","insertby":"1"}"""

    conn = http.client.HTTPConnection('doguz.io')
    conn.request('POST','/t20/index.php/api/datasync/afterdeviceconfig', body, headers)
    res = conn.getresponse()

    data = res.read()
    print(res.status, res.reason)
    print(data.decode('utf-8'))
    print(res.getheaders())
    #include 
    #include 

    int main(void)
    {
        CURL *curl;
        CURLcode res;

        curl = curl_easy_init();
        curl_easy_setopt(curl, CURLOPT_URL, "http://doguz.io/t20/index.php/api/datasync/afterdeviceconfig");
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
        /* if redirected, tell libcurl to follow redirection */
        curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);

        struct curl_slist *headers = NULL;
        headers = curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

        char *body ="token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&data={\"mac_id\":\"84:71:27:21:84:71\",\"ble_uuid\":\"12343800-203b-2f02-0000-000000120000\",\"ble_uuid_YN\":\"N\",\"major\":\"168\",\"major_YN\":\"N\",\"minor\":\"2\",\"minor_YN\":\"N\",\"transmission_interval\":\"100\",\"transmission_interval_YN\":\"N\",\"working_hour_st_time\":\"0\",\"working_hour_st_time_YN\":\"N\",\"working_hour_end_time\":\"23\",\"working_hour_end_time_YN\":\"N\",\"device_name\":\"Black Box\",\"device_name_YN\":\"N\",\"tx_power\":\"-1\",\"tx_power_YN\":\"N\",\"temp_mem_record_interval\":\"\",\"temp_mem_record_interval_YN\":\"N\",\"fw_ver\":\"5.0\",\"updt_time\":\"1620748663390\",\"insertby\":\"1\"}";
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body);

        /* Perform the request, res will get the return code */
        res = curl_easy_perform(curl);
        if (res != CURLE_OK) {
            fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
        }
        /* Clean up after yourself */
        curl_easy_cleanup(curl);
        return 0;
    }
    /* See: http://stackoverflow.com/a/2329792/1127848 of how to read data from the response. */
    URL url = new URL("http://doguz.io/t20/index.php/api/datasync/afterdeviceconfig");
    HttpURLConnection con = (HttpURLConnection) url.openConnection();
    con.setRequestMethod("POST");
    con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

    /* Payload support */
    con.setDoOutput(true);
    DataOutputStream out = new DataOutputStream(con.getOutputStream());
    out.writeBytes("token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&data={\"mac_id\":\"84:71:27:21:84:71\",\"ble_uuid\":\"12343800-203b-2f02-0000-000000120000\",\"ble_uuid_YN\":\"N\",\"major\":\"168\",\"major_YN\":\"N\",\"minor\":\"2\",\"minor_YN\":\"N\",\"transmission_interval\":\"100\",\"transmission_interval_YN\":\"N\",\"working_hour_st_time\":\"0\",\"working_hour_st_time_YN\":\"N\",\"working_hour_end_time\":\"23\",\"working_hour_end_time_YN\":\"N\",\"device_name\":\"Black Box\",\"device_name_YN\":\"N\",\"tx_power\":\"-1\",\"tx_power_YN\":\"N\",\"temp_mem_record_interval\":\"\",\"temp_mem_record_interval_YN\":\"N\",\"fw_ver\":\"5.0\",\"updt_time\":\"1620748663390\",\"insertby\":\"1\"}");
    out.flush();
    out.close();

    int status = con.getResponseCode();
    BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
    String inputLine;
    StringBuffer content = new StringBuffer();
    while((inputLine = in.readLine()) != null) {
        content.append(inputLine);
    }
    in.close();
    con.disconnect();
    System.out.println("Response status: " + status);
    System.out.println(content.toString());
    RestTemplate rest = new RestTemplate();
    HttpHeaders headers = new HttpHeaders();
    headers.add("Content-Type", "application/x-www-form-urlencoded");

    StringBuilder sb = new StringBuilder();
    sb.append("token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&data={\"mac_id\":\"84:71:27:21:84:71\",\"ble_uuid\":\"12343800-203b-2f02-0000-000000120000\",\"ble_uuid_YN\":\"N\",\"major\":\"168\",\"major_YN\":\"N\",\"minor\":\"2\",\"minor_YN\":\"N\",\"transmission_interval\":\"100\",\"transmission_interval_YN\":\"N\",\"working_hour_st_time\":\"0\",\"working_hour_st_time_YN\":\"N\",\"working_hour_end_time\":\"23\",\"working_hour_end_time_YN\":\"N\",\"device_name\":\"Black Box\",\"device_name_YN\":\"N\",\"tx_power\":\"-1\",\"tx_power_YN\":\"N\",\"temp_mem_record_interval\":\"\",\"temp_mem_record_interval_YN\":\"N\",\"fw_ver\":\"5.0\",\"updt_time\":\"1620748663390\",\"insertby\":\"1\"}");
    String body = sb.toString();

    HttpEntity requestEntity = new HttpEntity(body, headers);
    ResponseEntity responseEntity = rest.exchange("http://doguz.io/t20/index.php/api/datasync/afterdeviceconfig", HttpMethod.POST, requestEntity, String.class);
    HttpStatus httpStatus = responseEntity.getStatusCode();
    int status = httpStatus.value();
    String response = responseEntity.getBody();
    System.out.println("Response status: " + status);
    System.out.println(response);

Get Alert Details

 

This API returns all alert types in the Jido's API platform. you’ll need to send the Authenticated token’ as a GET parameter. A sample snippet of the code across various platforms are given below:

 

    curl "http://182.18.139.139/jido/index.php/api/datasync/getalerttypes?token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo" \
  -d "serial_no=X630000000000122&token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&log_date=2021-04-15" \
  -H "Content-Type: application/x-www-form-urlencoded"
    GET /jido/index.php/api/datasync/getalerttypes?token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo HTTP/1.1
    Host: 182.18.139.139:80
    Content-Type: application/x-www-form-urlencoded

    serial_no=X630000000000122&token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&log_date=2021-04-15
    const headers = new Headers();
    headers.append('Content-Type', 'application/x-www-form-urlencoded');

    const body = `serial_no=X630000000000122&token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&log_date=2021-04-15`;

    const init = {
      method: 'GET',
      headers,
      body
    };

    fetch('http://182.18.139.139/jido/index.php/api/datasync/getalerttypes?token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo', init)
    .then((response) => {
      return response.json(); // or .text() or .blob() ...
    })
    .then((text) => {
      // text is the response body
    })
    .catch((e) => {
      // error in e.message
    });
    (async () => {
      const headers = new Headers();
      headers.append('Content-Type', 'application/x-www-form-urlencoded');

      const body = `serial_no=X630000000000122&token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&log_date=2021-04-15`;

      const init = {
        method: 'GET',
        headers,
        body
      };

      const response = await fetch('http://182.18.139.139/jido/index.php/api/datasync/getalerttypes?token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo', init);
      console.log(`response status is ${response.status}`);
      const mediaType = response.headers.get('content-type');
      let data;
      if (mediaType.includes('json')) {
        data = await response.json();
      } else {
        data = await response.text();
      }
      console.log(data);
    })();
    const http = require('http');
    const init = {
      host: '182.18.139.139',
      path: '/jido/index.php/api/datasync/getalerttypes?token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo',
      method: 'GET',
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    };
    const callback = function(response) {
      let result = Buffer.alloc(0);
      response.on('data', function(chunk) {
        result = Buffer.concat([result, chunk]);
      });
      
      response.on('end', function() {
        // result has response body buffer
        console.log(result.toString());
      });
    };

    const req = http.request(init, callback);
    const body = `serial_no=X630000000000122&token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&log_date=2021-04-15`;
    req.write(body);
    req.end();
    var xhr = new XMLHttpRequest();
    xhr.addEventListener('load', function(e) {
      var response = e.target.responseText;
      console.log(response);
    });
    xhr.addEventListener('error', function(e) {
      console.error('Request errored with status', e.target.status);
    });
    xhr.open('GET', 'http://182.18.139.139/jido/index.php/api/datasync/getalerttypes?token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo');
    xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    var body = '';
    body += 'serial_no=X630000000000122&token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&log_date=2021-04-15';
    xhr.send(body);

    import requests

    url = 'http://182.18.139.139/jido/index.php/api/datasync/getalerttypes?token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo'
    headers = {'Content-Type': 'application/x-www-form-urlencoded'}
    body = """serial_no=X630000000000122&token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&log_date=2021-04-15"""

    req = requests.get(url, headers=headers, data=body)

    print(req.status_code)
    print(req.headers)
    print(req.text)
    import httplib

    headers = {'Content-Type': 'application/x-www-form-urlencoded'}
    body = """serial_no=X630000000000122&token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&log_date=2021-04-15"""

    conn = httplib.HTTPConnection('182.18.139.139')
    conn.request('GET','/jido/index.php/api/datasync/getalerttypes?token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo', body, headers)
    res = conn.getresponse()

    print(res.status, res.reason)
    print(res.read())
    print(res.getheaders())
    import http.client

    headers = {'Content-Type': 'application/x-www-form-urlencoded'}
    body = """serial_no=X630000000000122&token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&log_date=2021-04-15"""

    conn = http.client.HTTPConnection('182.18.139.139')
    conn.request('GET','/jido/index.php/api/datasync/getalerttypes?token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo', body, headers)
    res = conn.getresponse()

    data = res.read()
    print(res.status, res.reason)
    print(data.decode('utf-8'))
    print(res.getheaders())
    #include 
    #include 

    int main(void)
    {
        CURL *curl;
        CURLcode res;

        curl = curl_easy_init();
        curl_easy_setopt(curl, CURLOPT_URL, "http://182.18.139.139/jido/index.php/api/datasync/getalerttypes?token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo");
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET");
        /* if redirected, tell libcurl to follow redirection */
        curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);

        struct curl_slist *headers = NULL;
        headers = curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

        char *body ="serial_no=X630000000000122&token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&log_date=2021-04-15";
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body);

        /* Perform the request, res will get the return code */
        res = curl_easy_perform(curl);
        if (res != CURLE_OK) {
            fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
        }
        /* Clean up after yourself */
        curl_easy_cleanup(curl);
        return 0;
    }
    /* See: http://stackoverflow.com/a/2329792/1127848 of how to read data from the response. */
    URL url = new URL("http://182.18.139.139/jido/index.php/api/datasync/getalerttypes?token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo");
    HttpURLConnection con = (HttpURLConnection) url.openConnection();
    con.setRequestMethod("GET");
    con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

    /* Payload support */
    con.setDoOutput(true);
    DataOutputStream out = new DataOutputStream(con.getOutputStream());
    out.writeBytes("serial_no=X630000000000122&token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&log_date=2021-04-15");
    out.flush();
    out.close();

    int status = con.getResponseCode();
    BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
    String inputLine;
    StringBuffer content = new StringBuffer();
    while((inputLine = in.readLine()) != null) {
        content.append(inputLine);
    }
    in.close();
    con.disconnect();
    System.out.println("Response status: " + status);
    System.out.println(content.toString());
    RestTemplate rest = new RestTemplate();
    HttpHeaders headers = new HttpHeaders();
    headers.add("Content-Type", "application/x-www-form-urlencoded");

    StringBuilder sb = new StringBuilder();
    sb.append("serial_no=X630000000000122&token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&log_date=2021-04-15");
    String body = sb.toString();

    HttpEntity requestEntity = new HttpEntity(body, headers);
    ResponseEntity responseEntity = rest.exchange("http://182.18.139.139/jido/index.php/api/datasync/getalerttypes?token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo", HttpMethod.GET, requestEntity, String.class);
    HttpStatus httpStatus = responseEntity.getStatusCode();
    int status = httpStatus.value();
    String response = responseEntity.getBody();
    System.out.println("Response status: " + status);
    System.out.println(response);

Get Jido Alerts Data

 

To get historical alert data of an object using Jido's API platform, you’ll need to send the corresponding object’s ‘serial no’, ‘Alert date’ (i.e. a date for which you want to retrieve the device’s alert data), ‘Alert type’, ‘Authenticated token’. API will return the device’s alert data of the given alert date. A sample snippet of the code across various platforms are given below:

 

    curl "http://182.18.139.139/jido/index.php/api/datasync/getdevicealertdata" \
      -X POST \
      -d "alert_id=2&token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&alert_date=2021-04-15&serial_no=X630000000000122" \
      -H "Content-Type: application/x-www-form-urlencoded"
    POST /jido/index.php/api/datasync/getdevicealertdata HTTP/1.1
    Host: 182.18.139.139:80
    Content-Type: application/x-www-form-urlencoded

    alert_id=2&token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&alert_date=2021-04-15&serial_no=X630000000000122
    const headers = new Headers();
    headers.append('Content-Type', 'application/x-www-form-urlencoded');

    const body = `alert_id=2&token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&alert_date=2021-04-15&serial_no=X630000000000122`;

    const init = {
      method: 'POST',
      headers,
      body
    };

    fetch('http://182.18.139.139/jido/index.php/api/datasync/getdevicealertdata', init)
    .then((response) => {
      return response.json(); // or .text() or .blob() ...
    })
    .then((text) => {
      // text is the response body
    })
    .catch((e) => {
      // error in e.message
    });
    (async () => {
      const headers = new Headers();
      headers.append('Content-Type', 'application/x-www-form-urlencoded');

      const body = `alert_id=2&token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&alert_date=2021-04-15&serial_no=X630000000000122`;

      const init = {
        method: 'POST',
        headers,
        body
      };

      const response = await fetch('http://182.18.139.139/jido/index.php/api/datasync/getdevicealertdata', init);
      console.log(`response status is ${response.status}`);
      const mediaType = response.headers.get('content-type');
      let data;
      if (mediaType.includes('json')) {
        data = await response.json();
      } else {
        data = await response.text();
      }
      console.log(data);
    })();
    const http = require('http');
    const init = {
      host: '182.18.139.139',
      path: '/jido/index.php/api/datasync/getdevicealertdata',
      method: 'POST',
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    };
    const callback = function(response) {
      let result = Buffer.alloc(0);
      response.on('data', function(chunk) {
        result = Buffer.concat([result, chunk]);
      });
      
      response.on('end', function() {
        // result has response body buffer
        console.log(result.toString());
      });
    };

    const req = http.request(init, callback);
    const body = `alert_id=2&token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&alert_date=2021-04-15&serial_no=X630000000000122`;
    req.write(body);
    req.end();

    var xhr = new XMLHttpRequest();
    xhr.addEventListener('load', function(e) {
      var response = e.target.responseText;
      console.log(response);
    });
    xhr.addEventListener('error', function(e) {
      console.error('Request errored with status', e.target.status);
    });
    xhr.open('POST', 'http://182.18.139.139/jido/index.php/api/datasync/getdevicealertdata');
    xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    var body = '';
    body += 'alert_id=2&token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&alert_date=2021-04-15&serial_no=X630000000000122';
    xhr.send(body);
    import requests

    url = 'http://182.18.139.139/jido/index.php/api/datasync/getdevicealertdata'
    headers = {'Content-Type': 'application/x-www-form-urlencoded'}
    body = """alert_id=2&token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&alert_date=2021-04-15&serial_no=X630000000000122"""

    req = requests.post(url, headers=headers, data=body)

    print(req.status_code)
    print(req.headers)
    print(req.text)
    import httplib

    headers = {'Content-Type': 'application/x-www-form-urlencoded'}
    body = """alert_id=2&token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&alert_date=2021-04-15&serial_no=X630000000000122"""

    conn = httplib.HTTPConnection('182.18.139.139')
    conn.request('POST','/jido/index.php/api/datasync/getdevicealertdata', body, headers)
    res = conn.getresponse()

    print(res.status, res.reason)
    print(res.read())
    print(res.getheaders())
    import http.client

    headers = {'Content-Type': 'application/x-www-form-urlencoded'}
    body = """alert_id=2&token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&alert_date=2021-04-15&serial_no=X630000000000122"""

    conn = http.client.HTTPConnection('182.18.139.139')
    conn.request('POST','/jido/index.php/api/datasync/getdevicealertdata', body, headers)
    res = conn.getresponse()

    data = res.read()
    print(res.status, res.reason)
    print(data.decode('utf-8'))
    print(res.getheaders())
    #include 
    #include 

    int main(void)
    {
        CURL *curl;
        CURLcode res;

        curl = curl_easy_init();
        curl_easy_setopt(curl, CURLOPT_URL, "http://182.18.139.139/jido/index.php/api/datasync/getdevicealertdata");
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
        /* if redirected, tell libcurl to follow redirection */
        curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);

        struct curl_slist *headers = NULL;
        headers = curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

        char *body ="alert_id=2&token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&alert_date=2021-04-15&serial_no=X630000000000122";
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body);

        /* Perform the request, res will get the return code */
        res = curl_easy_perform(curl);
        if (res != CURLE_OK) {
            fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
        }
        /* Clean up after yourself */
        curl_easy_cleanup(curl);
        return 0;
    }
    /* See: http://stackoverflow.com/a/2329792/1127848 of how to read data from the response. */
    URL url = new URL("http://182.18.139.139/jido/index.php/api/datasync/getdevicealertdata");
    HttpURLConnection con = (HttpURLConnection) url.openConnection();
    con.setRequestMethod("POST");
    con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

    /* Payload support */
    con.setDoOutput(true);
    DataOutputStream out = new DataOutputStream(con.getOutputStream());
    out.writeBytes("alert_id=2&token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&alert_date=2021-04-15&serial_no=X630000000000122");
    out.flush();
    out.close();

    int status = con.getResponseCode();
    BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
    String inputLine;
    StringBuffer content = new StringBuffer();
    while((inputLine = in.readLine()) != null) {
        content.append(inputLine);
    }
    in.close();
    con.disconnect();
    System.out.println("Response status: " + status);
    System.out.println(content.toString());
    RestTemplate rest = new RestTemplate();
    HttpHeaders headers = new HttpHeaders();
    headers.add("Content-Type", "application/x-www-form-urlencoded");

    StringBuilder sb = new StringBuilder();
    sb.append("alert_id=2&token=xxxJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsImFwaV91c2VyX2lkIjoiMSIsImlzX2xvZ2dlZF9pbiI6dHJ1ZX0.Q15N4mtgpazPtRJ7x_9ZlfF1ecsUSa8fkSvKWLVRzpo&alert_date=2021-04-15&serial_no=X630000000000122");
    String body = sb.toString();

    HttpEntity requestEntity = new HttpEntity(body, headers);
    ResponseEntity responseEntity = rest.exchange("http://182.18.139.139/jido/index.php/api/datasync/getdevicealertdata", HttpMethod.POST, requestEntity, String.class);
    HttpStatus httpStatus = responseEntity.getStatusCode();
    int status = httpStatus.value();
    String response = responseEntity.getBody();
    System.out.println("Response status: " + status);
    System.out.println(response);

 

Technical Support Center

Click Here

 

Configuration Doc

 

T20 Configurator Application Process Flow

View Configuration Doc

 

User Guide

 

AlerWear T20 Step by Step User Guide V1.0

View User Doc

Let's Get In Touch!


Ready to start your next project with us?
That's great! Give us a call or send us an email and we will get back to you as soon as possible!

Black Box Network Services India Pvt. Ltd.

+91 990 309 1725 / +91 907 392 9780

Copyright © 2024 Sxtreo. All Rights Reserved.