Tipro API
Communicate with Tipro devices
Tipro API

1. Introduction

Tipro API enables communictation with Tipro devices.

It uses libusb/hidapi library (github.com/libusb/hidapi) to comunicate through USB HID interface.

2. Installation

2.1 Install HIDAPI (https://github.com/libusb/hidapi):

Run the commands:

sudo apt update
sudo apt upgrade
sudo apt install git
git clone git://github.com/libusb/hidapi.git
sudo apt install libudev-dev libusb-1.0-0-dev
sudo apt install autotools-dev autoconf automake libtool
cd hidapi
./bootstrap
./configure
make
sudo make install

2.2 Install Tipro library (support@tipro.si):

tar -xvzf tiprohidapi.tar.gz
sudo cp libtiprohidapi.so /usr/local/lib/
sudo ldconfig

3. Usage

Include "TiproHidLinux.h" file and module files you want to communicate with, e.g. "BF22.h"

Example code:

#include <iostream>
#include "TiproHidLinux.h"
#include "BF22.h"

int main(int argc, char** argv) 
{
    int res;
    std::cout << std::hex;
    
    //instance of TiproHid object   
    TiproHid hid = TiproHid();
    
    //find Tipro devices
    hid.Enumerate();

    //count found devices
    unsigned int numDevices = hid.Count();
    if (numDevices>0)
    {
        std::cout << numDevices << " Tipro device(s) found." << std::endl;

        //get first device
        TiproHidDevice *device = hid.GetDevice(0);

        //open it
        res = device->Open();
        if (res == 0)
        {
            std::cout << "First device open." << std::endl;

            //enumerate its modules
            res = device->TiproEnumerateModules();
            if (res == 0)
            {
                std::cout << "Modules of first device enumerated.\n" << std::endl;

                //comunicate with the device
                
                //if it is BF22 device, you can turn on leds on line keys
                res = TiproBF22SetLineKeysLedState(device, BF22_LED_GREEN, BF22_LED_ORANGE, BF22_LED_RED,
                    BF22_LED_BLINK_GREEN_OFF, BF22_LED_BLINK_OFF_GREEN, BF22_LED_BLINK_ORANGE_OFF,
                    BF22_LED_BLINK_OFF_ORANGE, BF22_LED_BLINK_RED_OFF, BF22_LED_BLINK_OFF_RED,
                    BF22_LED_NOCHANGE, BF22_LED_NOCHANGE, BF22_LED_NOCHANGE, BF22_LED_NOCHANGE,
                    BF22_LED_NOCHANGE, BF22_LED_BLINK_GREEN_RED, BF22_LED_BLINK_RED_GREEN);
                    
                std::cout << "HIDBF22SetLineKeysLedState " << res << " " << std::endl;
                
                
            }
            else
            {
                std::cout << "HIDEnumerateModules error: " << res << std::endl;
            }
        }
        else
        {
            std::cout << "DeviceOpen error: " << res << std::endl;
        }

        //close the device
        device->Close();
    }
    else
    {
        std::cout << "No Tipro device found." << std::endl;
    }

    return 0; 
}