# Licensing and Setting up Trillbit Host library

## Access your TrillBit developer account

1. Create or login to your TrillBit Developer account at: <https://developers.trillbit.com/>
2. On the home page, you will see platforms supported with 15 evaluation licenses for platforms- Android, iOS, Embedded and Knowles SmartMic host boards.&#x20;
3. On selection of Knowles platform, you will see:&#x20;
   1. Section to download Credentials file-credentials.json for licensing the Trillbit SDK for your application.&#x20;
   2. Section with a link to Github page for Trillbit SDK for Knowles.\
      Pre-compiled binary <mark style="color:blue;">**“**</mark> [<mark style="color:blue;">**IA611-SAMD21-DEMO1.bin**</mark>](https://github.com/Trillbit-Inc/TrillbitSDK-knowles/blob/main/IA611-SAMD21-DEMO/Binfiles/IA611-SAMD21-DEMO1.bin)<mark style="color:blue;">**”**</mark> is available to download from the github repository-  <https://github.com/Trillbit-Inc/TrillbitSDK-knowles/tree/main/IA611-SAMD21-DEMO/Binfiles>
4. [Host source code github](https://github.com/Trillbit-Inc/TrillbitSDK-knowles) page would contain:
   1. Pre-compiled host-library for the platform SAMD21.
   2. Demo application for SAMD21 and corresponding source code. &#x20;
   3. Python script for licensing procedure.&#x20;
   4. Supporting documents and User guides.

## Get your credentials file

This credentials file is required for the authentication and licensing of your Trillbit SDK.&#x20;

Please access your credentials file and download here-<https://developers.trillbit.com/>

## Setup the host-board

Connect the IA611 Xplained Pro extension board to **EXT2** connector of SAMD21 Xplained Pro board as shown below.

[![Board connections](https://github.com/Trillbit-Inc/TrillbitSDK-knowles/raw/main/IA611-SAMD21-DEMO/Documents/images/board.jpg)](https://github.com/Trillbit-Inc/TrillbitSDK-knowles/blob/main/IA611-SAMD21-DEMO/Documents/images/board.jpg)

## Setup Serial Terminal Program

You can use any serial terminal program to view the output from Demo application. This document will use Tera Term.

Demo application uses EDBG UART to communicate with PC/User.

Connect the *DEBUG USB* port of the board to PC with a micro USB cable and open Tera Term. EDBG COM Port number on your PC may be different.

[![COM Port Selection](https://github.com/Trillbit-Inc/TrillbitSDK-knowles/raw/main/IA611-SAMD21-DEMO/Documents/images/tera_term_com.jpg)](https://github.com/Trillbit-Inc/TrillbitSDK-knowles/blob/main/IA611-SAMD21-DEMO/Documents/images/tera_term_com.jpg)

Demo application configures EDBG UART as 115200 8-n-1.

To set this settings in Tera Term, select Menu *Setup -> Serial Port* and enter values as shown below, then click button *New Settings*.

[![Serial Port Setup](https://github.com/Trillbit-Inc/TrillbitSDK-knowles/raw/main/IA611-SAMD21-DEMO/Documents/images/tera_term_serial_setting.jpg)](https://github.com/Trillbit-Inc/TrillbitSDK-knowles/blob/main/IA611-SAMD21-DEMO/Documents/images/tera_term_serial_setting.jpg)

To correctly display Demo output in Tera Term, select Menu *Setup -> Terminal* and enter values as shown below, then click button *OK*. Ignore the locale, output will be only ASCII.

[![Serial Port Setup](https://github.com/Trillbit-Inc/TrillbitSDK-knowles/raw/main/IA611-SAMD21-DEMO/Documents/images/tera_term_terminal_setting.jpg)](https://github.com/Trillbit-Inc/TrillbitSDK-knowles/blob/main/IA611-SAMD21-DEMO/Documents/images/tera_term_terminal_setting.jpg)

## Flash the Demo Binary

The demo binary is located on the [Trillbit repository](https://github.com/Trillbit-Inc/TrillbitSDK-knowles)-at Binfiles/IA611-SAMD21-DEMO.bin

Connect the *DEBUG USB* port of the board to PC with a micro USB cable. On Windows OS, File explorer will open up showing the *XPLAINED* drive contents.

Copy-Paste the demo binary to this *XPLAINED* drive. Copying process may take some time as on-chip debugger flashes the binary. NOTE: You will not see the binary file in the *XPLAINED* drive once copying is done. Check serial terminal output after copying is done.

### Alternatively- Create your own binary

You may also compile the host-library at <https://github.com/Trillbit-Inc/TrillbitSDK-knowles>, to create your own binary for the SAMD21 host board.&#x20;

To do so, use- <https://www.microchip.com/en-us/tools-resources/develop/microchip-studio>.&#x20;

Note: This use of this tool is only be supported on Windows.&#x20;

## Getting Trillbit Host SDK License

If this is the first time board was flashed or reflashed after chip erase then you will see a license not found message on serial terminal.

[![Unlicensed](https://github.com/Trillbit-Inc/TrillbitSDK-knowles/raw/main/IA611-SAMD21-DEMO/Documents/images/unlicensed.jpg)](https://github.com/Trillbit-Inc/TrillbitSDK-knowles/blob/main/IA611-SAMD21-DEMO/Documents/images/unlicensed.jpg)

### Setup Python Environment

Ensure you have python3 installed on your PC. Open command prompt shell (Not Power Shell) and run the following commands in the *scripts* folder.

```
> python -m venv py_env
> py_env\Scripts\activate.bat
> pip install pyserial requests

* Run with sudo in commands if permission is denied. 
```

Before running the license program disconnect Tera Term from Menu *File -> Disconnect*, otherwise license program will report permission or busy error.

Once python setup is complete run the license program in the *scripts* folder.

Follow the instructions the from the license program. If successful you will see LED0 on SAMD21 board blink once when IA61x is configured. And blink 4 times when Trillbit algorithm accepts authentication and is ready for data detection.

## License your SDK

1. Run the license\_devic&#x65;*\_*&#x73;cript.py file and provide the path to the credentials file downloaded.&#x20;

If not downloaded already, please download the credentials.json file from the TrillBit dev-portal.&#x20;

```
>python3 license_device_script.py <path-to-thecredentials-file>
```

3\. The license\_d*evice\_*&#x73;cript.py file will proceed to license your board.&#x20;

4\. You will now see the message<mark style="color:yellow;">:</mark>

```
 "Trillbit IA61x Algorithm is ready. Listening for data over sound…." 
```

Your device is now licensed and ready to be integrated with the Trillbit library.&#x20;

You may now disconnect the host board from your computer.&#x20;

## Using the Demo

After License was downloaded in the previous step, SAMD21 was ready to detect data however since the Tera Term was disconnected you won't see any messages.

Connect Tera Term again and press the *RESET* switch on SAMD21 board. You will see messages as below on the terminal. When you see the message indicating algorithm is ready for data detection, play some data sound on the TrillPlay app. Point the phone/speaker towards IA611 board. Currently only SSI0 is supported.

The number before *Data Detected* event indicates how many events were detected till now. The number in the Payload parentheses indicates payload length.

[![Success Output](https://github.com/Trillbit-Inc/TrillbitSDK-knowles/raw/main/IA611-SAMD21-DEMO/Documents/images/success.jpg)](https://github.com/Trillbit-Inc/TrillbitSDK-knowles/blob/main/IA611-SAMD21-DEMO/Documents/images/success.jpg)

## Sending data from TrillPlay

You may use the TrillApp - <https://play.google.com/store/apps/details?id=com.trill.play> , as the sender configuration your mobile phone, to send messages to the SmartMic IA61x.

<br>

##
