Log out
Current signal
Signals
Menu
...
+
Clone signal
My Signals
Menu
Current panel
Panels
Menu
...
+
My Panels
Menu
Scheme
Timeline
Map
<
>
Arduino
+ESP01
NodeMCU
ESP32
Linux
Raspbian
Java
Web
Javascript
Java libraries for Circus.
Name CircusJAVALib-1.0.0
Description Implements ReadValue and WriteValue in JAVA.
Download CircusJavaLib1.1.0.java circusofthings.com.jar CircusJavaLib1.1.0.zip
Hardware Any running JAVA
Java specification
CircusLib
com.circusofthings.api.ver110

Class CircusLib

  • java.lang.Object
    • com.circusofthings.api.ver110.CircusLib


  • public class CircusLib
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String VERSION 
    • Constructor Summary

      Constructors 
      Constructor and Description
      CircusLib(java.lang.String token) 
    • Constructor Detail

      • CircusLib

        public CircusLib(java.lang.String token)
        Parameters:
        token - Is the token provided in your account to get access to the api server.
    • Method Detail

      • writeValue

        public JSONObject writeValue(java.lang.String key,
                                     double value,
                                     double lat,
                                     double lon,
                                     double alt)
        Parameters:
        key - The key of the signal to be feeded.
        value - The value to be actually written as the current output.
        lat - The latitude value to be set
        lon - The longitude value to be set
        alt - The altitude value to be set
        Returns:
        An org.json.JSONObject will be returned.
        String Status = Status code of the response given by the Circus Server. Get the value using: (org.json.JSONObject).getString("Status").
        String Message = Status message of the response given by the Circus Server. Get the value using: (org.json.JSONObject).getString("Message").
        Possible status / messages
        200 = Success.
        400 = The syntax of the query is wrong.
        401 = The API token is unknown or no longer available.
        403 = Insuficient permissions to write this signal.
        404 = Signal key not found.
      • writeValue

        public JSONObject writeValue(java.lang.String key,
                                     double lat,
                                     double lon,
                                     double alt)
        Parameters:
        key - The key of the signal to be feeded.
        lat - The latitude value to be set
        lon - The longitude value to be set
        alt - The altitude value to be set
        Returns:
        An org.json.JSONObject will be returned.
        String Status = Status code of the response given by the Circus Server. Get the value using: (org.json.JSONObject).getString("Status").
        String Message = Status message of the response given by the Circus Server. Get the value using: (org.json.JSONObject).getString("Message").
        Possible status / messages
        200 = Success.
        400 = The syntax of the query is wrong.
        401 = The API token is unknown or no longer available.
        403 = Insuficient permissions to write this signal.
        404 = Signal key not found.
      • writeValue

        public JSONObject writeValue(java.lang.String key,
                                     double value)
        Parameters:
        key - The key of the signal to be feeded.
        value - The value to be actually written as the current output.
        Returns:
        An org.json.JSONObject will be returned.
        String Status = Status code of the response given by the Circus Server. Get the value using: (org.json.JSONObject).getString("Status").
        String Message = Status message of the response given by the Circus Server. Get the value using: (org.json.JSONObject).getString("Message").
        Possible status / messages
        200 = Success.
        400 = The syntax of the query is wrong.
        401 = The API token is unknown or no longer available.
        403 = Insuficient permissions to write this signal.
        404 = Signal key not found.
      • readValue

        public JSONObject readValue(java.lang.String key)
        Parameters:
        key - The key of the signal to be checked.
        Returns:
        An org.json.JSONObject will be returned.
        String Status = Status code of the response given by the Circus Server. Get the value using: (org.json.JSONObject).getString("Status").
        String Message = Status message of the response given by the Circus Server. Get the value using: (org.json.JSONObject).getString("Message").
        String Value = Current value (double) for the signal. Get the value using: (org.json.JSONObject).getString("Value").
        Possible status / messages
        200 = Success.
        400 = The syntax of the query is wrong.
        403 = Insuficient permissions to read this signal.
        404 = Signal key not found.
Java examples

I made a class named IncreasingValue which is used to feed the Increasing value posted at Circus for test purposes.

            package com.circusofthings.examples.javaclient;

            import com.circusofthings.api.ver110.CircusLib;
            import org.json.JSONObject;

            public class IncreasingValue extends Thread
            {
                private final String key;
                private final String token;
                private static final long FREC = 20000L;

                public IncreasingValue(String key, String token)
                {
                  this.key = key;
                  this.token = token;
                }

                public void run()
                {
                    CircusLib commands = new CircusLib(token);
                    double value = 0;
                    for (;;) {
                        value++;
                        if(value>1000){value=0;}
                        JSONObject json = commands.writeValue(key, value);
                        System.out.println(json.toString());
                        try {
                            Thread.sleep(FREC);
                        } catch (InterruptedException ex) {
                            Thread.currentThread().interrupt();
                        }
                    }
                }
            }
                            

It can be run adding this two lines in your code:

IncreasingValue increasingValue = new IncreasingValue("3456", "your_token_here");
increasingValue.start();
Circus Experiments with JAVA.
Experiment
Basic Warwalking with a Raspberry
Thing type
Raspberry
Firmware
Java