Skip to content

Lite API: OCF

Gyeonghwan Hong edited this page Dec 21, 2020 · 7 revisions

Parent Document: ANT APIs

OCF API takes charge of supporting OCF (Open Connectivity Foundation) standard-based communication.

The OCF API is composed of OCF-server functions and OCF-client functions.

You need to load OCF API module before you use its API as following.

var ocfAPI = require('ocf');

There is example applications to implement a OCF server or a OCF client.

  • apps/ocf_client.js
  • apps/ocf_server.js
  • apps/ocf_client_multi.js
  • apps/ocf_server_multi.js

OCF Common

OCF.getAdapter()

  • OCFAdapter OCFAdapter(void)
    • Get the singleton OCF adapter. OCF adapter manages the event loop of a OCF client and a OCF server.
    • Return: OCFAdapter
      • Resulting OCFAdapter object

OCFAdapter.initialize()

  • void OCFAdapter.initialize(void)
    • Initialize the OCF adapter. It sets the internal data structures managed by OCF thread.

OCFAdapter.deinitialize()

  • void OCFAdapter.deinitialize(void)
    • Deinitialize the OCF adapter. It resets the internal data structures managed by OCF thread.

OCFAdapter.onPrepareEventLoop()

  • void OCFAdapter.onPrepareEventLoop(Function handler)
    • Set the event handler called when the OCF thread's event loop becomes ready.

OCFAdapter.start()

  • void OCFAdapter.start()
    • Start the OCF adapter and launch the OCF thread.

OCFAdapter.stop()

  • void OCFAdapter.stop()
    • Stop the OCF adapter and terminate the OCF thread.

OCFAdapter.setPlatform()

  • void OCFAdapter.setPlatform(String mfgName)
    • Set this device's platform type

OCFAdapter.getPlatform()

  • String OCFAdapter.getPlatform()
    • Get this device's platform type

OCFAdapter.addDevice()

  • void OCFAdapter.addDevice(String URI, String resourceType, String name, String specVersion, String dataModelVersion)
    • Add a device resource that this OCF adapter serves

OCFAdapter.getDevices()

  • Array OCFAdapter.getDevices()
    • Get the device resources that this OCF adapter is or will be serving

OCFAdapter.getDevice()

  • OCFDevice OCFAdapter.getDevice(Integer index)
    • Get a specific device resource that this OCF adapter is or will be serving

OCF Representation

OCFAdapter.repStartRootObject()

OCFAdapter.repSet()

OCFAdapter.repEndRootObject()

OCF Server

OCFAdapter.onPrepareServer()

OCF.createResource()

OCFAdapter.addResource()

OCFAdapter.deleteResource()

OCFAdapter.getResources()

OCFAdapter.sendResponse()

OCF Client

OCFAdapter.onPrepareClient()

OCFAdapter.discovery()

OCFAdapter.stopDiscovery()

OCFAdapter.isDiscovering()

OCFAdapter.observe()

OCFAdapter.stopObserve()

OCFAdapter.get()

OCFAdapter.delete()

OCFAdapter.initPost()

OCFAdapter.post()

OCFAdapter.initPut()

OCFAdapter.put()