ANDROID

Thingsboard Client - Android java

ZEROWIN.TECH 2022. 1. 30. 13:17
728x90

client side

 

  • Telemetry Upload
Server 에서 업로드 된 데이터 확인
   

안드로이드 소스코드

* 클라이언트에서 서버로 데이터를 업데이트합니다.

String url = "https://thingsboard.cloud/api/v1/" + TOKEN + "/telemetry";

JSONObject jsonObject = null;
try {
    jsonObject = new JSONObject( "{\"temperature\":10, \"humidity\":100 }" );
}
catch (JSONException e) { e.printStackTrace(); }
String jsonString = jsonObject.toString();

DoHttpRequest(url, jsonString, "POST","", new Callback() {
    @Override
    public void onError(String error) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                // You got error,

                System.out.println("onError=" + error);
            }
        });
    }

    @Override
    public void onSuccess(String result) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                // You sucessfully fetched content
                System.out.println("onSuccess=" + result);
            }
        });
    }
});
  • Swtich Control

서버에서 버튼으로 디바이스 제어

Knob control 추가

안드로이드 박스 디버깅

knob control debug

 

CURL Test

 

 

참조사이트

https://github.com/thingsboard/samples/blob/master/android-things/GpioControlSample/app/src/main/java/org/thingsboard/sample/gpiocontrol/GpioControlActivity.java

 

GitHub - thingsboard/samples: Thingboard sample applications

Thingboard sample applications. Contribute to thingsboard/samples development by creating an account on GitHub.

github.com

 

'ANDROID' 카테고리의 다른 글

wifi adb on android  (0) 2022.05.20
Thingsboard Client - Android java  (0) 2022.01.30