Skip to main content

HDK for C-One

Don't know what a C-One is ? The answer is here.

The HDK API is designed with RxJava2.

Prerequisites#

For the first generation of products, the app CpcSystemServices at version 2.1.0 or above needs to be installed on the device. For second generation CoreService app must be installed instead of CpcSystemServices. Please contact Coppernic Support in case of difficulties.

Use Pins of C-One's expansion port#

  • Get a GpioPort instance:
private GpioPort gpioPort;
@Overridepublic void onStart() {    super.onStart();    GpioPort.GpioManager.get()        .getGpioSingle(getContext())        .observeOn(AndroidSchedulers.mainThread())        .subscribe(new Consumer<GpioPort>() {            @Override            public void accept(GpioPort g) throws Exception {                gpioPort = g;            }        });}
  • Use it:
RESULT res = gpioPort.setPin1(true)

Observe input pin state#

//Register an observer to the input stateDisposable d = GpioPort.observeInputPin4(getContext(), 200, TimeUnit.MILLISECONDS)                // Be notified only when value is changing                .distinctUntilChanged()                .observeOn(AndroidSchedulers.mainThread())                .subscribe(new Consumer<Boolean>() {                    @Override                    public void accept(Boolean aBoolean) throws Exception {                        //Do something                    }                });//Dispose the observer when you are doned.dispose()