[[ANT]]

* What is BCA_Lib? [#c8ccebc6]
“BCA_Lib” is a library, which uses with BC-ANT-USB. This library makes the configuration of ANT communication simple. For more information of ANT protocol, please look at ANT's community page, “thisisant.com.” The details of BC-ANT-USB is listed on ANT/BC-ANT-USB of BC::labs.

The class reference of BCA_lib is published on this page. 

** Features of BCA_Lib [#r97f1b06]
The major features of this library are listed below.
- Open/close ANT devices
- Receive data/events
- Transmit data
- Pairing process
- The size of transmitting and receiving data is 8byte

The features of API are
- Callback I/F(Interface)
- C++ class I/F (Interface)
There are two types of I/Fs. You may use either one of two I/Fs.

* Files [#g3b17237]
[Caution]~
To use this library, 5 files listed below and the driver for BC-ANT-USB are required.~

- AntCallbackInterface.h: Callback interface header file.
- AntDevice.h: C++ class interface header file.
- BCA_Lib.dll: The whole library 
- BCA_Lib.lib: Import library
- bc_abstract.dll: A support library developed by BeatCraft, Inc.
- BCA-Lib.zip: The details of BCA_Lib (written in HTML format), BC-ANT-USB driver, and sample programs. The details of contents are listed below
-- bin: this contains bc_abstract.dll, BCA_Lib.dll, and BCA_Lib.lib. The details are shown above.
-- driver: BC-ANT-USB driver
-- html: A HTML formatted document, which explains the details of BCA_Lib. (To read this document, please click index.html)
-- include: ANTCallbackInterface.h, AntDecice.h, and BCA_Lib.h
-- python_sample: Python sample programs, which handle transmitting, receiving, and pairing (receiving side only)
-- sample: C++ sample programs, which manage transmitting, receiving, and pairing (receiving side only)

* Definitions [#g7223d38]
- Chanel Type:~
Specify the transmitter (sender) as MASTER and receiver as SLAVE

- Channel Number:~
8 channels of ANT communications are available at an ANT device

- Share Channel:~
It defines whether Shared Cannel is applied or not.~
The details of Shared Channel are explained in the later section.~

- Device Number:~
This is a value, which is unique to a specific device. (It can be the serial number of a device). The cause of wildcard, which specifies this number as 0, cannot be applicable to a MASTER (transmitting, or sending) device.

- Device Type:~
This value defines device type. Select a number form 1 to 127. 0 can be used as wildcard. However, wildcard cannot apply to a MASTER (transmitter or sender) device.

- Transmission Type:~
This defines characteristics of communication of a device. Specify a number from 1 to 255. Wildcard, 0, can be used for only SLAVE (receiver) devices.

- Frequency:~
2.4GHz band is used.~
API defined a frequency own formula.~ 
Please input the number, which is determined by subtracting 2400 from the selected Mega frequency (MHz). i.e. 2466MHz is the selected frequency, the input number is 66 since 66 = 2466-2600.

- Channel Period
The intervals between sending or receiving data is 0.5Hz ~ 32768Hz

* About Communication [#k869809c]
- The values of Channel ID (device number, device type, and trans mission type) and frequency must be identical between transmitting and receiving devices as they establish ANT communication. (In some case, receiving devices may select wildcard.)
- If wildcard is selected, the receiving channel receives only the data from the transmitting device that the channel has been established and pared with first.

**  Example of Configuration [#z55c3cda]
[Transmitting side]~
Channel Number: 0~
Channel Type: 0 (MASTER)~
Shared Channel: 0~
Device Number: 33~
Device Type: 1~
Transmission Type: 1~
Frequency: 66 (2466MHz: Since 2466-2400 =66)~
Channel Period; 4Hz~

Example code (transmitting data): this uses the callback interface.~

[Receiving side]~
Channel Number: 0~
Channel Type: 0 (MASTER)~
Shared Channel: 0~
Device Number: 33~
Device Type: 1~
Transmission Type: 0 (Wildcard)~
Frequency: 66 (2466MHz: Since 2466-2400 =66)~
Channel Period: 4Hz~

Example code (receiving data)

* About Pairing [#saf1d856]
- Pairing is a way to establish a communication between two devices, specifically.~

[Transmitting#1]~
Channel Number: 0~
Channel Type: 0 (MASTER)~
Device Number: 1234~
Frequency: 66 (2466MHz: Since 2466-2400 =66)~
Channel Period: 4Hz~

[Transmitting#2]~
Channel Number: 0~
Channel Type: 0 (MASTER)~
Device Number: 5678~
Frequency: 66 (2466MHz: Since 2466-2400 =66)~
Channel Period: 4Hz~

[Receiving]~
Channel Number: 0~
Channel Type: 1 (SLAVE)~
Device Number: 0~
Frequency: 66 (2466MHz: Since 2466-2400 =66)~
Channel Period: 4Hz~

Example Code~

The registered (BCA_RegisterPairingFunc()) callback function is executed after the pairing process (BCA_STARTPairing()) has been executed and the selected duration of time has passed. The channel information, such as Device ID, of a newly found device is handed over to the function.~
As the device, which you like to connect, is selected from the application of UI, the channel is opened (BCA_OpenChannel()).~

The device search is performed by all 8 channels, so 8 devices would be found at most.~

**Reference [#p90ce375]
- Function Reference (C++ I/F)
- Function Reference (callback I/F)

* Shared Channel [#w329e6d6]
** About Shared Channel [#jb87d670]
The common connection types of ANT network are 1-to-1 or broadcast connection.~
Excluding broadcast, as a master connects to multiple slaves, the master needs to connect to each slave, independently.
図1
Shard Channel is a way that a single master connects to multiple slaves in one channel.
In Shared Channel, specific shared addresses are configured to all slaves. To add a shared address to a slave, the address consumes 2 bytes, and the total amount of data, which can be sent in one transmission, is reduced to 6 bytes. 
図2
An example of transmitting data 
図3
To send data, which includes a specific shared address from a mater, a node, which corresponds to a specific shared address that each slave has sent to the master, receives the data.

As the nodes start receiving the data, the nodes send back data, whose first 2bytes include own shared addresses, in broadcast.

Notify shared addresses on a shared channel

*** Example of Configuration [#x3f5be0a]
Configuration of Node A~
Channel Number: 0~
Channel Type:  BCA_CHANNEL_TYPE_MASTER~
Shared Channel: BCA_CHANNEL_SHARED
Device Number: 33 (the serial number of node A)
Device Type: 3 (the device type of node A)
Transmission Type: 3 (2bytes of shared channel address)~
Frequency: 66 (2466MHz: Since 2466-2400 =66)~
Channel Period: 4Hz~ 

Configuration of Node B, C, and D~
Channel Number: 0~
Channel Type:  BCA_CHANNEL_TYPE_SLAVE~
Shared Channel: BCA_CHANNEL_SHARED
Device Number: 33 (the serial number of node A)
Device Type: 3 (the device type of node A)
Transmission Type: 3 (2bytes of shared channel address)~
Frequency: 66 (2466MHz: Since 2466-2400 =66)~
Channel Period: 4Hz~ 


As the slaves (node B, C, and D) has completed opening own channels, they add own shared addresses to the first 2bytes of the data and send back the data in broadcast. Since now on, slaves reply as sending back the data which includes shared addresses at its first 2 bytes. Otherwise, the information of the configured shared address is void.

* Sample Code [#b186a823]
There are sets of sample code for transmitting, receiving, and pairing (receiving only). One is for C++, and the other is for Python.

** C++ Samples [#i1b14c4d]
- SendCB.zip: Sample code for sending
- RecvCB.zip: Sample code for receiving
- PairingCB.zip: Sample code for pairing (receiving only)

** Python Examples [#pafd1f9e]
- BCA_send.py: Sample code for sending
- BCA_recv.py: Sample code for receiving
- BCA_pairing.py: Sample code for pairing (receiving only)

** Whole files, BCA_lib, and HTML document [#f0e5cda7]
- BCA_Lib.zip


Front page   New List of pages Search Recent changes   RSS of recent changes