Skip to content

Lite API: Companion

Hayun Lee edited this page Dec 21, 2020 · 5 revisions

Parent Document: ANT APIs

Companion API comprises of connection-handling functions and message-transmission functions.

ANT framework supports communication with smartphone companion.

Companion API internally calls P2P communication functions to transmit the message requested by applications. As now, ANT Lite supports only Internet-based connection with companion device. P2P-based connection (ex. Bluetooth or Wi-Fi Direct) will be supported soon.

var companionAPI = require('ant').companion;

Connection Handling

registerOnReciveMessage()

registerOnReciveMessage(Function handler);

registerOnReceiveMessage() registers a function to be executed when a message is received.

  • handler: Callback function

unregisterOnReceiveMessage()

Boolean unregisterOnReceiveMessage(Function handler);

unregisterOnReceiveMessage() removes a function to be executed when a message is received.

  • handler: Callback function

getMyIPAddress()

String getMyIPAddress(String interfaceName);

getMyIPAddress() returns the IP address of interfaceName.

  • interfaceName: Interface name

Message Transmission

sendMessage()

Boolean sendMessage(String message);

sendMessage() sends a message.

  • message: Message to send