Search code examples
javaeclipse-hono

How to integrate electronic lock tracker (JT701) with Eclipse Hono using custom HttpAdaptor


I would like to now how I could integrate an electronic lock tracker (JT701) device to hono using the adapters mechanism. The device in question is using Jt600 protocol. Unfortunately for us, we can not change the device in order to use hono API (neither http or mqtt)


Solution

  • Hono uses the protocol adapters to mediate between the devices' transport protocol and the AMQP 1.0 protocol which is used internally by Hono and which also used for Hono's north bound (application facing) APIs.

    Hono comes with several standard adapters for HTTP, MQTT, AMQP 1.0, LoRaWAN and (experimental) SigFox and CoAP.

    If a device uses a proprietary protocol that cannot be mapped/adapted to the endpoints exposed by the standard adapters, then there are two possible ways to make the devices work with Hono:

    1. Implement a custom protocol adapter which exposes an endpoint that implements the device protocol and integrates with Hono's APIs. This process is described at https://www.eclipse.org/hono/docs/dev-guide/custom_http_adapter/ as pointed out already in the comments.
    2. Implement a protocol proxy in front of one of the existing standard adapters. In your case, the proxy would speak JT600 with the device and connect to the AMQP 1.0 adapter, forwarding data hence and forth. This concept is described in https://github.com/eclipse/hono/issues/1478.

    The first approach is mostly suitable for implementing new adapters that have the potential of becoming standard adapters to be included with Hono out of the box, e.g. an adapter for a widely used standard protocol. It requires deep understanding of Hono's APIs in order to be properly implemented. The advantage of this approach is that the adapter can become part of Hono's code base.

    The second approach is better suited for proprietary protocols that you do not want to expose or if you need/want to have more control over the code itself. The biggest advantage of this approach is that it is easier to do because you only need to integrate with the AMQP 1.0 adapter's device facing endpoints and do not need to care how to integrate with all the other Hono APIs. Note, however, that with this approach you cannot take advantage of Hono's Credentials API for storing credentials used for authenticating devices.