Biblioteki SDK Dla Kalkulatora Kodów Do Radia

Biblioteki programistyczne SDK dla PHP, Python, JavaScript i C# kalkulatora kodów odblokowujących radioodtwarzacze w samochodach.

Opis

Aby skorzystać ze wszystkich funkcji Kalkulatora Kodów Do Radia API, użyj gotowych pakietów SDK dla swojego języka programowania.

Usługa Web API bazuje na prostym zapytaniu POST i odpowiedzi zakodowanej w postaci JSON.

Instalacja

W celu szybszego wdrożenia, paczki instalacyjne interfejsu Web API zostały wgrane na popularne repozytoria, a ich kody źródłowe zostały dodatkowo opublikowane na GitHubie:

Język Instalacja SDK Źródła
Język programowania PHP

Uruchom komendę:

php composer.phar require --prefer-dist pelock/radio-code-calculator "*"

lub dodaj do sekcji require w pliku konfiguracyjnym composer.json wpis:

"pelock/radio-code-calculator": "*"
Packagist GitHub
Język programowania Python pip install radio-code-calculator PyPI GitHub
Język programowania JavaScript

Uruchom komendę:

npm i radio-code-calculator

lub dodaj do sekcji dependencies w pliku konfiguracyjnym package.json wpis:

"dependencies": {
  "radio-code-calculator": "latest"
},

npm GitHub

Formaty danych wejściowych

Każdy kalkulator wymaga innego formatu danych wejściowych, takich jak numer seryjny radia, aby poprawnie wygenerować kod odblokowujący. W przypadku podania błędnego formatu danych nie będzie możliwe wygenerowanie kodu odblokowującego.

Formaty danych są weryfikowane w bibliotece programistycznej w trybie online oraz opcjonalnie w trybie offline. Poniżej prezentujemy wymagane formaty dla danych wejściowych:

Model Opis Długość RegEx (PCRE)
Renault i Dacia Kalkulator i Generator Kodu RadiaRenault i Dacia PreCode, gdzie pierwszy znak to zawsze litera A..Z, a po niej występują trzy cyfry 0..9. 4 /^([A-Z]{1}[0-9]{3})$/
Ford Kod Do Radia M Seria Kalkulator i Generator Kodu RadiaFord M Seria Pre code składa się z sześciu cyfr (zignoruj i NIE WPISUJ pierwszej literki M). 6 /^([0-9]{6})$/
Ford Kod Do Radia V Seria Kalkulator i Generator Kodu RadiaFord V Seria Pre code składa się z sześciu cyfr (zignoruj i NIE WPISUJ pierwszej literki V). 6 /^([0-9]{6})$/
Ford TravelPilot EX, FX i NX Kod Do Radia Generator i KalkulatorFord TravelPilot EX, FX i NX Ostatnie 7 cyfr numeru seryjnego. 7 /^([0-9]{7})$/
Toyota ERC Kalkulator i Generator Kodu Do Odblokowania RadiaToyota ERC Kod ERC składa się z 16 cyfr i liter. 16 /^([A-Z0-9]{16})$/i
Jeep Cherokee Kod Do Odblokowania Radia Kalkulator i GeneratorJeep Cherokee Numer seryjny składa się z 14 znaków i cyfr (pomiń spacje). Upewnij się, że kod dostawcy (ang. supplier code) zaczyna się od cyfr 17719. 14 /^([A-Z0-9]{10}[0-9]{4})$/i
Chrysler Panasonic TM9 Kalkulator i Generator Kodu Do RadiaChrysler Panasonic TM9 Ostatnie 4 cyfry numeru seryjnego. Upewnij się, że numer seryjny rozpoczyna się od znaków TM9 np. T M9 XXX X X1234. 4 /^([0-9]{4})$/
Fiat Stilo i Bravo Kod Do Radia Visteon Kalkulator i GeneratorFiat Stilo i Bravo (Visteon) Pre code składa się z sześciu cyfr (zignoruj i NIE WPISUJ pierwszej literki M). 6 /^([A-Z0-9]{6})$/i
Fiat DAIICHI Kod Do Radia MOPAR Kalkulator i GeneratorFiat DAIICHI MOPAR Ostatnie 4 cyfry numeru seryjnego (zignoruj i NIE WPISUJ pierwszej literki). 4 /^([0-9]{4})$/i
Nissan Kalkulator Kodu PIN z Numeru SchowkaNissan PIN Immobilizera Kod schowka składa się z 12 cyfr i liter. 12 /^([A-Z0-9]{12})$/i
Eclipse ESN Kalkulator Kodu OdblokowującegoEclipse ESN Kod ESN składa się z 6 cyfr i liter. 6 /^([A-Z0-9]{6})$/i
Jaguar Alpine Kalkulator Kodu Odblokowującego Radio SamochodoweJaguar Alpine Ostatnie 5 cyfr numeru seryjnego. 5 /^([0-9]{5})$/

Przykłady użycia

Generowanie kodu radiowego

W tym przykładzie zaprezentowane jest generowanie kodu dla wybranego modelu radiowego. Cała walidacja parametrów wejściowych odbywa się po stronie serwera i jeśli numer seryjny radia będzie posiadał nieprawidłową długość lub wzorzec - usługa zwróci błąd.

<?php declare(strict_types=1);

/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example, we will demonstrate how to generate a code for a specific
 * type of car radio.
 *
 * Version      : v1.1.0
 * PHP          : >= 8
 * Dependencies : cURL
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2023 PELock LLC
 * @license Apache-2.0
 *
/*****************************************************************************/

//
// include Radio Code Calculator API module
//
use PELock\RadioCodeCalculator\RadioCodeCalculator;
use PELock\RadioCodeCalculator\RadioErrors;
use PELock\RadioCodeCalculator\RadioModels;

//
// create Radio Code Calculator API class instance (we are using our activation key)
//
$myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

//
// generate radio code (using Web API)
//
list($error, $result) = $myRadioCodeCalculator->calc(RadioModels::get(RadioModels::FORD_M_SERIES), "123456");

switch($error)
{
        case RadioErrors::SUCCESS: echo "Radio code is " . $result["code"]; break;
        case RadioErrors::INVALID_RADIO_MODEL: echo "Invalid radio model (not supported)"; break;
        case RadioErrors::INVALID_SERIAL_LENGTH: echo "Invalid serial number length (expected " . $result["serialMaxLen"] . " characters)"; break;
        case RadioErrors::INVALID_SERIAL_PATTERN: echo "Invalid serial number regular expression pattern (expected " . $result["serialRegexPattern"]["php"] . " regex pattern)"; break;
        case RadioErrors::INVALID_SERIAL_NOT_SUPPORTED: echo "This serial number is not supported"; break;
        case RadioErrors::INVALID_EXTRA_LENGTH: echo "Invalid extra data length (expected " . $result["extraMaxLen"] . " characters)"; break;
        case RadioErrors::INVALID_EXTRA_PATTERN: echo "Invalid extra data regular expression pattern (expected " . $result["extraRegexPattern"]["php"] . " regex pattern"; break;
        case RadioErrors::INVALID_INPUT: echo "Invalid input data"; break;
        case RadioErrors::INVALID_COMMAND: echo "Invalid command sent to the Web API interface"; break;
        case RadioErrors::INVALID_LICENSE: echo "Invalid license key!"; break;
        default: echo "Something unexpected happen while trying to login to the service (error code {error})."; break;
}
#!/usr/bin/env python

###############################################################################
#
# Radio Code Calculator API - WebApi interface usage example
#
# In this example, we will demonstrate how to generate a code for a specific
# type of car radio.
#
# Version        : v1.1.0
# Language       : Python
# Author         : Bartosz Wójcik
# Project        : https://www.pelock.com/products/radio-code-calculator
# Homepage       : https://www.pelock.com
#
###############################################################################

#
# include Radio Code Calculator API module
#
from radio_code_calculator import *

#
# create Radio Code Calculator API class instance (we are using our activation key)
#
myRadioCodeCalculator = RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD")

#
# generate radio code (using Web API)
#
error, result = myRadioCodeCalculator.calc(RadioModels.FORD_M_SERIES, "123456")

if error == RadioErrors.SUCCESS:
    print(f'Radio code is {result["code"]}')
elif error == RadioErrors.INVALID_RADIO_MODEL:
    print("Invalid radio model (not supported)")
elif error == RadioErrors.INVALID_SERIAL_LENGTH:
    print(f'Invalid serial number length (expected {result["serialMaxLen"]} characters)')
elif error == RadioErrors.INVALID_SERIAL_PATTERN:
    print(f'Invalid serial number regular expression pattern (expected {result["serialRegexPattern"]["python"]} regex pattern)')
elif error == RadioErrors.INVALID_SERIAL_NOT_SUPPORTED:
    print("This serial number is not supported")
elif error == RadioErrors.INVALID_EXTRA_LENGTH:
    print(f'Invalid extra data length (expected {result["extraMaxLen"]} characters)')
elif error == RadioErrors.INVALID_EXTRA_PATTERN:
    print(f'Invalid extra data regular expression pattern (expected {result["extraRegexPattern"]["python"]} regex pattern)')
elif error == RadioErrors.INVALID_INPUT:
    print("Invalid input data")
elif error == RadioErrors.INVALID_COMMAND:
    print("Invalid command sent to the Web API interface")
elif error == RadioErrors.INVALID_LICENSE:
    print("Invalid license key")
elif error == RadioErrors.ERROR_CONNECTION:
    print("Something unexpected happen while trying to login to the service.")
else:
    print(f'Unknown error {error}')
"use strict";

/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example, we will demonstrate how to generate a code for a specific
 * type of car radio.
 *
 * Version      : v1.1.0
 * JS           : ES6
 * Dependencies : radio-code-calculator
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2023 PELock LLC
 * @license Apache-2.0
 *
/*****************************************************************************/

//
// include Radio Code Calculator API module
//
import { RadioCodeCalculator, RadioErrors, RadioModel, RadioModels } from "radio-code-calculator";

//
// create Radio Code Calculator API class instance (we are using our activation key)
//
let myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

//
// generate radio code (using Web API)
//
myRadioCodeCalculator.calc(RadioModels.FORD_M_SERIES, "123456").then((result) => {

    console.log("Radio code is " + result["code"]);

}).catch((error) => {

    switch(error["error"])
    {
    case RadioErrors.INVALID_RADIO_MODEL: console.log("Invalid radio model (not supported)"); break;
    case RadioErrors.INVALID_SERIAL_LENGTH: console.log("Invalid serial number length (expected " + result["serialMaxLen"] + " characters)"); break;
    case RadioErrors.INVALID_SERIAL_PATTERN: console.log("Invalid serial number regular expression pattern (expected " + result["serialRegexPattern"]["php"] + " regex pattern)"); break;
    case RadioErrors.INVALID_SERIAL_NOT_SUPPORTED: console.log("This serial number is not supported"); break;
    case RadioErrors.INVALID_EXTRA_LENGTH: console.log("Invalid extra data length (expected " + result["extraMaxLen"] + " characters)"); break;
    case RadioErrors.INVALID_EXTRA_PATTERN: console.log("Invalid extra data regular expression pattern (expected " + result["extraRegexPattern"]["php"] + " regex pattern"); break;
    case RadioErrors.INVALID_INPUT: console.log("Invalid input data"); break;
    case RadioErrors.INVALID_COMMAND: console.log("Invalid command sent to the Web API interface"); break;
    case RadioErrors.INVALID_LICENSE: console.log("Invalid license key!"); break;
    default: console.log(`Something unexpected happen while trying to login to the service (error code ${error}).`); break;
    }
});

Generowanie kodu radiowego z dodatkową walidacją w trybie offline

Kody radiowe generowane są na podstawie wejściowych parametrów takich jak m.in. numer seryjny radia.

Numery seryjne radia różnią się dla różnych raddioodtwarzaczy, mają różną długość i różny wzór, jedne mogą się składać z samych cyfr np. 1234, a inne z cyfr i liter np. AB1234XYZ.

Walidacja tych danych odbywa się po stronie serwera. Jednak dla usprawnienia działania, możemy wykorzystać informacje o dostępnych limitach i wzorcach poszczególnych numerów seryjnych, aby np. ustawić te ograniczenia w kontrolkach we własnych aplikacjach bez zbędnego wywoływania zapytań do interfejsu Web API.

<?php declare(strict_types=1);

/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example, we will demonstrate how to generate a code for a specific
 * type of car radio. This example shows how to use an extended offline
 * validation.
 *
 * Version      : v1.1.0
 * PHP          : >= 8
 * Dependencies : cURL
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2023 PELock LLC
 * @license Apache-2.0
 *
/*****************************************************************************/

//
// include Radio Code Calculator API module
//
use PELock\RadioCodeCalculator\RadioCodeCalculator;
use PELock\RadioCodeCalculator\RadioErrors;
use PELock\RadioCodeCalculator\RadioModel;
use PELock\RadioCodeCalculator\RadioModels;

//
// create Radio Code Calculator API class instance (we are using our activation key)
//
$myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

//
// generate a single radio unlocking code
//
$serial = "123456";
$extra = "";

//
// select a radio model
//
$radioModel = RadioModels::get(RadioModels::FORD_M_SERIES);

//
// display radio model information, you can use it to set limits in your controls e.g.
//
// textFieldRadioSerial.maxLength = radioModel->serial_max_len
// textFieldRadioSerial.regEx = radioModel->serial_regex_pattern()
//
// (if allowed by your controls)
//
echo "Radio model $radioModel->name expects a serial number of $radioModel->serial_max_len length and {$radioModel->serial_regex_pattern()} regex pattern<br>";

// additional information
if ($radioModel->extra_max_len > 0)
{
        echo "Additionally an extra field is required with $radioModel->extra_max_len and {$radioModel->extra_regex_pattern()} regex pattern<br>";
}

//
// validate the serial number (offline) before sending the Web API request
//
$error = $radioModel->validate($serial, $extra);

if ($error !== RadioErrors::SUCCESS)
{
    if ($error === RadioErrors::INVALID_SERIAL_LENGTH)
        echo "Invalid serial number length (expected $radioModel->serial_max_len characters<br>";
    else if ($error == RadioErrors::INVALID_SERIAL_PATTERN)
        echo "Invalid serial number regular expression pattern (expected $radioModel->serial_regex_pattern() regex pattern)<br>";
    else if ($error == RadioErrors::INVALID_SERIAL_NOT_SUPPORTED)
        echo "This serial number is not supported";
    else if ($error == RadioErrors::INVALID_EXTRA_LENGTH)
        echo "Invalid extra data length (expected $radioModel->extra_max_len characters)<br>";
    else if ($error == RadioErrors::INVALID_EXTRA_PATTERN)
        echo "Invalid extra data regular expression pattern (expected $radioModel->extra_regex_pattern() regex pattern)<br>";

    exit(1);
}

//
// generate radio code (using Web API)
//
list($error, $result) = $myRadioCodeCalculator->calc($radioModel, $serial);

switch($error)
{
        case RadioErrors::SUCCESS: echo "Radio code is " . $result["code"]; break;
        case RadioErrors::INVALID_RADIO_MODEL: echo "Invalid radio model (not supported)"; break;
        case RadioErrors::INVALID_SERIAL_LENGTH: echo "Invalid serial number length (expected " . $result["serialMaxLen"] . " characters)"; break;
        case RadioErrors::INVALID_SERIAL_PATTERN: echo "Invalid serial number regular expression pattern (expected " . $result["serialRegexPattern"]["php"] . " regex pattern)"; break;
        case RadioErrors::INVALID_SERIAL_NOT_SUPPORTED: echo "This serial number is not supported"; break;
        case RadioErrors::INVALID_EXTRA_LENGTH: echo "Invalid extra data length (expected " . $result["extraMaxLen"] . " characters)"; break;
        case RadioErrors::INVALID_EXTRA_PATTERN: echo "Invalid extra data regular expression pattern (expected " . $result["extraRegexPattern"]["php"] . " regex pattern"; break;
        case RadioErrors::INVALID_INPUT: echo "Invalid input data"; break;
        case RadioErrors::INVALID_COMMAND: echo "Invalid command sent to the Web API interface"; break;
        case RadioErrors::INVALID_LICENSE: echo "Invalid license key!"; break;
        default: echo "Something unexpected happen while trying to login to the service (error code {error})."; break;
}
#!/usr/bin/env python

###############################################################################
#
# Radio Code Calculator API - WebApi interface usage example
#
# In this example, we will demonstrate how to generate a code for a specific
# type of car radio. This examples shows how to use an extended offline
# validation.
#
# Version        : v1.1.0
# Language       : Python
# Author         : Bartosz Wójcik
# Project        : https://www.pelock.com/products/radio-code-calculator
# Homepage       : https://www.pelock.com
#
###############################################################################

#
# include Radio Code Calculator API module
#
from radio_code_calculator import *

#
# create Radio Code Calculator API class instance (we are using our activation key)
#
myRadioCodeCalculator = RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD")

#
# generate a single radio unlocking code
#
serial: str = "123456"
extra: str = ""

#
# select a radio model
#
radioModel: RadioModel = RadioModels.FORD_M_SERIES

#
# display radio model information, you can use it to set limits in your controls e.g.
#
# textFieldRadioSerial.maxLength = radioModel.serial_max_len
# textFieldRadioSerial.regEx = radioModel.serial_regex_pattern
#
# (if allowed by your controls)
#
print(f'Radio model {radioModel.name} expects a serial number of {radioModel.serial_max_len}'
      f' length and {radioModel.serial_regex_pattern} regex pattern')

# additional information
if radioModel.extra_max_len > 0:
    print(f'Additionally an extra field is required with {radioModel.extra_max_len} and'
          f' and {radioModel.extra_regex_pattern} regex pattern')

#
# validate the serial number (offline) before sending the Web API request
#
error = radioModel.validate(serial, extra)

if error != RadioErrors.SUCCESS:

    if error == RadioErrors.INVALID_SERIAL_LENGTH:
        print(f'Invalid serial number length (expected {radioModel.serial_max_len} characters)')
    elif error == RadioErrors.INVALID_SERIAL_PATTERN:
        print(f'Invalid serial number regular expression pattern (expected {radioModel.serial_regex_pattern} regex pattern)')
    elif error == RadioErrors.INVALID_SERIAL_NOT_SUPPORTED:
        print("This serial number is not supported")
    elif error == RadioErrors.INVALID_EXTRA_LENGTH:
        print(f'Invalid extra data length (expected {radioModel.extra_max_len} characters)')
    elif error == RadioErrors.INVALID_EXTRA_PATTERN:
        print(f'Invalid extra data regular expression pattern (expected {radioModel.extra_regex_pattern} regex pattern)')
    exit(1)

#
# generate radio code (using Web API)
#
error, result = myRadioCodeCalculator.calc(radioModel, "123456")

if error == RadioErrors.SUCCESS:
    print(f'Radio code is {result["code"]}')
elif error == RadioErrors.INVALID_RADIO_MODEL:
    print("Invalid radio model (not supported)")
elif error == RadioErrors.INVALID_SERIAL_LENGTH:
    print(f'Invalid serial number length (expected {result["serialMaxLen"]} characters)')
elif error == RadioErrors.INVALID_SERIAL_PATTERN:
    print(f'Invalid serial number regular expression pattern (expected {result["serialRegexPattern"]["python"]} regex pattern)')
elif error == RadioErrors.INVALID_SERIAL_NOT_SUPPORTED:
    print("This serial number is not supported")
elif error == RadioErrors.INVALID_EXTRA_LENGTH:
    print(f'Invalid extra data length (expected {result["extraMaxLen"]} characters)')
elif error == RadioErrors.INVALID_EXTRA_PATTERN:
    print(f'Invalid extra data regular expression pattern (expected {result["extraRegexPattern"]["python"]} regex pattern)')
elif error == RadioErrors.INVALID_INPUT:
    print("Invalid input data")
elif error == RadioErrors.INVALID_COMMAND:
    print("Invalid command sent to the Web API interface")
elif error == RadioErrors.INVALID_LICENSE:
    print("Invalid license key")
elif error == RadioErrors.ERROR_CONNECTION:
    print("Something unexpected happen while trying to login to the service.")
else:
    print(f'Unknown error {error}')
"use strict";

/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example, we will demonstrate how to generate a code for a specific
 * type of car radio. This example shows how to use an extended offline
 * validation.
 *
 * Version      : v1.1.0
 * JS           : ES6
 * Dependencies : radio-code-calculator
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2023 PELock LLC
 * @license Apache-2.0
 *
/*****************************************************************************/

//
// include Radio Code Calculator API module
//
import { RadioCodeCalculator, RadioErrors, RadioModel, RadioModels } from "radio-code-calculator";

//
// create Radio Code Calculator API class instance (we are using our activation key)
//
let myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

//
// generate a single radio unlocking code
//
let serial = "123456";
let extra = "";

//
// select a radio model
//
let radioModel = RadioModels.FORD_M_SERIES;

//
// display radio model information, you can use it to set limits in your controls e.g.
//
// textFieldRadioSerial.maxLength = radioModel.serial_max_len
// textFieldRadioSerial.regEx = radioModel.serial_regex_pattern()
//
// (if allowed by your controls)
//
console.log(`Radio model ${radioModel.name} expects a serial number of ${radioModel.serial_max_len} length and ${radioModel.serial_regex_pattern()} regex pattern<br>`);

// additional information
if (radioModel.extra_max_len > 0)
{
    console.log(`Additionally an extra field is required with ${radioModel.extra_max_len} and ${radioModel.extra_regex_pattern()} regex pattern<br>`);
}

//
// validate the serial number (offline) before sending the Web API request
//
let error = radioModel.validate(serial, extra);

if (error !== RadioErrors.SUCCESS)
{
    if (error === RadioErrors.INVALID_SERIAL_LENGTH)
        console.log(`Invalid serial number length (expected ${radioModel.serial_max_len} characters<br>`);
    else if (error == RadioErrors.INVALID_SERIAL_PATTERN)
        console.log(`Invalid serial number regular expression pattern (expected ${radioModel.serial_regex_pattern()} regex pattern)<br>`);
    else if (error == RadioErrors.INVALID_SERIAL_NOT_SUPPORTED)
        console.log("This serial number is not supported");
    else if (error == RadioErrors.INVALID_EXTRA_LENGTH)
        console.log(`Invalid extra data length (expected ${radioModel.extra_max_len} characters)<br>`);
    else if (error == RadioErrors.INVALID_EXTRA_PATTERN)
        console.log(`Invalid extra data regular expression pattern (expected ${radioModel.extra_regex_pattern()} regex pattern)<br>`);

    process.exit(1);
}

//
// generate radio code (using Web API)
//
myRadioCodeCalculator.calc(radioModel, serial).then((result) => {

    console.log("Radio code is " + result["code"]);

}).catch((error) => {

    switch(error["error"])
    {
    case RadioErrors.INVALID_RADIO_MODEL: console.log("Invalid radio model (not supported)"); break;
    case RadioErrors.INVALID_SERIAL_LENGTH: console.log("Invalid serial number length (expected " + result["serialMaxLen"] + " characters)"); break;
    case RadioErrors.INVALID_SERIAL_PATTERN: console.log("Invalid serial number regular expression pattern (expected " + result["serialRegexPattern"]["php"] + " regex pattern)"); break;
    case RadioErrors.INVALID_SERIAL_NOT_SUPPORTED: console.log("This serial number is not supported"); break;
    case RadioErrors.INVALID_EXTRA_LENGTH: console.log("Invalid extra data length (expected " + result["extraMaxLen"] + " characters)"); break;
    case RadioErrors.INVALID_EXTRA_PATTERN: console.log("Invalid extra data regular expression pattern (expected " + result["extraRegexPattern"]["php"] + " regex pattern"); break;
    case RadioErrors.INVALID_INPUT: console.log("Invalid input data"); break;
    case RadioErrors.INVALID_COMMAND: console.log("Invalid command sent to the Web API interface"); break;
    case RadioErrors.INVALID_LICENSE: console.log("Invalid license key!"); break;
    default: console.log(`Something unexpected happen while trying to login to the service (error code ${error}).`); break;
    }
});

Pobieranie listy obsługiwanych kalkulatorów radiowych

Jeśli chciałbyś pobrać informację o wszystkich obsługiwanych modelach radioodtwarzaczy oraz ich parametrach takich jak długość numeru seryjnego i wzorzec - możesz to zrobić.

<?php declare(strict_types=1);

/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example we will list all the available calculators and, their
 * parameters like name, maximum length of the radio serial number and its
 * regex pattern.
 *
 * Version      : v1.1.0
 * PHP          : >= 8
 * Dependencies : cURL
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2023 PELock LLC
 * @license Apache-2.0
 *
/*****************************************************************************/

//
// include Radio Code Calculator API module
//
use PELock\RadioCodeCalculator\RadioCodeCalculator;
use PELock\RadioCodeCalculator\RadioErrors;

//
// create Radio Code Calculator API class instance (we are using our activation key)
//
$myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

//
// get the list of the supported radio calculators and their parameters (max. length, regex pattern)
//
list($error, $radio_models) = $myRadioCodeCalculator->list();

if ($error == RadioErrors::SUCCESS)
{
        echo "Supported radio models " . count($radio_models) . "<br>";

        foreach ($radio_models as $radio_model)
        {
                echo "Radio model name - $radio_model->name<br>";

                echo "Max. length of the radio serial number - " . $radio_model->serial_max_len . "<br>";
                echo "Regex pattern for the radio serial number - " . $radio_model->serial_regex_pattern() . "<br>";

                // is extra field specified?
                if ($radio_model->extra_max_len > 0)
                {
                        echo "Max. length of the radio extra data - " . $radio_model->extra_max_len . "<br>";
                        echo "Regex pattern for the radio extra data - " . $radio_model->extra_regex_pattern() . "<br>";
                        echo "<br>";
                }
        }
}
else if ($error == RadioErrors::INVALID_LICENSE)
        echo "Invalid license key!";
else
        echo "Something unexpected happen while trying to login to the service (error code {error}).";
#!/usr/bin/env python

###############################################################################
#
# Radio Code Calculator API - WebApi interface usage example
#
# In this example we will list all the available calculators, and their
# parameters like name, maximum length of the radio serial number and its
# regex pattern.
#
# Version        : v1.1.0
# Language       : Python
# Author         : Bartosz Wójcik
# Project        : https://www.pelock.com/products/radio-code-calculator
# Homepage       : https://www.pelock.com
#
###############################################################################

#
# include Radio Code Calculator API module
#
from radio_code_calculator import *

#
# create Radio Code Calculator API class instance (we are using our activation key)
#
myRadioCodeCalculator = RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD")

#
# get the list of the supported radio calculators and their parameters (max. length, regex pattern)
#
error, radio_models = myRadioCodeCalculator.list()

if error == RadioErrors.SUCCESS:

    print(f'Supported radio models {len(radio_models)}:\n')

    for radio_model in radio_models:

        print(f'Radio model name - {radio_model.name}')

        print(f'Max. length of the radio serial number - {radio_model.serial_max_len}')
        print(f'Regex pattern for the radio serial number - {radio_model.serial_regex_pattern}')

        # is extra field specified?
        if radio_model.extra_max_len > 0:
            print(f'Max. length of the radio extra data - {radio_model.extra_max_len}')
            print(f'Regex pattern for the radio extra data - {radio_model.extra_regex_pattern}')

        print()

elif error == RadioErrors.INVALID_LICENSE:
    print("Invalid license key!")
else:
    print(f'Something unexpected happen while trying to login to the service (error code {error}).')
"use strict";

/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example we will list all the available calculators and, their
 * parameters like name, maximum length of the radio serial number and its
 * regex pattern.
 *
 * Version      : v1.1.0
 * JS           : ES6
 * Dependencies : radio-code-calculator
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2023 PELock LLC
 * @license Apache-2.0
 *
/*****************************************************************************/

//
// include Radio Code Calculator API module
//
import { RadioCodeCalculator, RadioErrors, RadioModel, RadioModels } from "radio-code-calculator";

//
// create Radio Code Calculator API class instance (we are using our activation key)
//
let myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

//
// get the list of the supported radio calculators and their parameters (max. length, regex pattern)
//
myRadioCodeCalculator.list().then((result) => {

    let radio_models = result["radioModels"];

    console.log("Supported radio models " + radio_models.length + "<br>");

    radio_models.forEach(radio_model => {

        console.log("Radio model name - " + radio_model.name + "<br>");

        console.log("Max. length of the radio serial number - " + radio_model.serial_max_len + "<br>");
        console.log("Regex pattern for the radio serial number - " + radio_model.serial_regex_pattern() + "<br>");

        // is extra field specified?
        if (radio_model.extra_max_len > 0)
        {
            console.log("Max. length of the radio extra data - " + radio_model.extra_max_len + "<br>");
            console.log("Regex pattern for the radio extra data - " + radio_model.extra_regex_pattern() + "<br>");
            console.log("<br>");
        }

    });

}).catch((error) => {

    if (error["error"] == RadioErrors.INVALID_LICENSE)
        console.log("Invalid license key!");
    else
        console.log(`Something unexpected happen while trying to login to the service (error code ${error}).`);
});

Pobieranie parametrów wybranego kalkulatora radiowego

Możliwe jest pobranie parametrów wybranego kalkulatora

<?php declare(strict_types=1);

/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example, we will demonstrate how to get information about the
 * specific radio calculator and its parameters (max. length & regex pattern).
 *
 * Version      : v1.1.0
 * PHP          : >= 8
 * Dependencies : cURL
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2023 PELock LLC
 * @license Apache-2.0
 *
/*****************************************************************************/

//
// include Radio Code Calculator API module
//
use PELock\RadioCodeCalculator\RadioCodeCalculator;
use PELock\RadioCodeCalculator\RadioErrors;

//
// create Radio Code Calculator API class instance (we are using our activation key)
//
$myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

//
// query information about the radio model
//
list($error, $radio_model) = $myRadioCodeCalculator->info("ford-m-series");

if ($error === RadioErrors::SUCCESS)
{
	echo "Radio model name - " . $radio_model->name . "<br>";

	echo "Max. length of the radio serial number - " . $radio_model->serial_max_len . "<br>";
	echo "Regex pattern for the radio serial number - " . $radio_model->serial_regex_pattern() . "<br>";

	// is extra field specified?
	if ($radio_model->extra_max_len > 0)
	{
		echo "Max. length of the radio extra data - " . $radio_model->extra_max_len . "<br>";
		echo "Regex pattern for the radio extra data - " . $radio_model->extra_regex_pattern() . "<br>";
		echo "<br>";
	}
}
elseif ($error == RadioErrors::INVALID_LICENSE)
    echo "Invalid license key!";
else
    echo "Something unexpected happen while trying to login to the service (error code {error}).";
#!/usr/bin/env python

###############################################################################
#
# Radio Code Calculator API - WebApi interface usage example
#
# In this example, we will demonstrate how to get information about the
# specific radio calculator and its parameters (max. length & regex pattern).
#
# Version        : v1.1.0
# Language       : Python
# Author         : Bartosz Wójcik
# Project        : https://www.pelock.com/products/radio-code-calculator
# Homepage       : https://www.pelock.com
#
###############################################################################

#
# include Radio Code Calculator API module
#
from radio_code_calculator import *

#
# create Radio Code Calculator API class instance (we are using our activation key)
#
myRadioCodeCalculator = RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD")

#
# query information about the radio model
#
error, radioModel = myRadioCodeCalculator.info("ford-m-series")

if error == RadioErrors.SUCCESS:

    print(f'Radio model name - {radioModel.name}')

    print(f'Max. length of the radio serial number - {radioModel.serial_max_len}')
    print(f'Regex pattern for the radio serial number - {radioModel.serial_regex_pattern}')

    # is extra field specified?
    if radioModel.extra_max_len > 0:
        print(f'Max. length of the radio extra data - {radioModel.extra_max_len}')
        print(f'Regex pattern for the radio extra data - {radioModel.extra_regex_pattern}')

    print()

elif error == RadioErrors.INVALID_LICENSE:
    print("Invalid license key!")
else:
    print(f'Something unexpected happen while trying to login to the service (error code {error}).')
"use strict";

/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example, we will demonstrate how to get information about the
 * specific radio calculator and its parameters (max. length & regex pattern).
 *
 * Version      : v1.1.0
 * JS           : ES6
 * Dependencies : radio-code-calculator
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2023 PELock LLC
 * @license Apache-2.0
 *
/*****************************************************************************/

//
// include Radio Code Calculator API module
//
import { RadioCodeCalculator, RadioErrors, RadioModel, RadioModels } from "radio-code-calculator";

//
// create Radio Code Calculator API class instance (we are using our activation key)
//
let myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

//
// query information about the radio model
//
myRadioCodeCalculator.info("ford-m-series").then((result) => {

    let radio_model = result["radioModel"];

    console.log("Radio model name - " + radio_model.name + "<br>");

    console.log("Max. length of the radio serial number - " + radio_model.serial_max_len + "<br>");
    console.log("Regex pattern for the radio serial number - " + radio_model.serial_regex_pattern() + "<br>");

    // is extra field specified?
    if (radio_model.extra_max_len > 0)
    {
        console.log("Max. length of the radio extra data - " + radio_model.extra_max_len + "<br>");
        console.log("Regex pattern for the radio extra data - " + radio_model.extra_regex_pattern() + "<br>");
        console.log("<br>");
    }

}).catch((error) => {
    if (error.error == RadioErrors.INVALID_LICENSE)
        console.log("Invalid license key!");
    else
        console.log(`Something unexpected happen while trying to login to the service (error code ${error["error"]}).`);
});

Sprawdzanie klucza aktywacyjnego

Sprawdzając status klucza aktywacyjnego, uzyskamy informacje o właścicielu licencji, jej typie oraz dacie wygaśnięcia licencji.

<?php declare(strict_types=1);

/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example we will verify our activation key status.
 *
 * Version      : v1.1.0
 * PHP          : >= 8
 * Dependencies : cURL
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2023 PELock LLC
 * @license Apache-2.0
 *
/*****************************************************************************/

//
// include Radio Code Calculator API module
//
use PELock\RadioCodeCalculator\RadioCodeCalculator;
use PELock\RadioCodeCalculator\RadioErrors;

//
// create Radio Code Calculator API class instance (we are using our activation key)
//
$myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

//
// login to the service
//
list($error, $result) = $myRadioCodeCalculator->login();

//
// result[] array holds the information about the license
//
// result["license"]["activationStatus"] - True if license is active, False on invalid/expired keys
// result["license"]["userName"] - user name/company name of the license owner
// result["license"]["type"] - license type (0 - Personal License, 1 - Company License)
// result["license"]["expirationDate"] - license expiration date (in YYYY-MM-DD format)
//
if ($error == RadioErrors::SUCCESS)
{
    echo "License activation status - " . ($result["license"]["activationStatus"] ? "True" : "False") . "<br>";
    echo "License owner - " . $result["license"]["userName"];
    echo "License type - " . ($result["license"]["type"] == 0 ? "Personal" : "Company") . "<br>";
    echo "Expiration date - " . $result["license"]["expirationDate"] . "<br>";
}
else if ($error == RadioErrors::INVALID_LICENSE)
    echo "Invalid license key!";
else
    echo "Something unexpected happen while trying to login to the service (error code {error}).";
#!/usr/bin/env python

###############################################################################
#
# Radio Code Calculator API - WebApi interface usage example
#
# In this example we will verify our activation key status.
#
# Version        : v1.1.0
# Language       : Python
# Author         : Bartosz Wójcik
# Project        : https://www.pelock.com/products/radio-code-calculator
# Homepage       : https://www.pelock.com
#
###############################################################################

#
# include Radio Code Calculator API module
#
from radio_code_calculator import *

#
# create Radio Code Calculator API class instance (we are using our activation key)
#
myRadioCodeCalculator = RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD")

#
# login to the service
#
error, result = myRadioCodeCalculator.login()

#
# result[] array holds the information about the license
#
# result["license"]["activationStatus"] - True if license is active, False on invalid/expired keys
# result["license"]["userName"] - user name/company name of the license owner
# result["license"]["type"] - license type (0 - Personal License, 1 - Company License)
# result["license"]["expirationDate"] - license expiration date (in YYYY-MM-DD format)
#
if error == RadioErrors.SUCCESS:
    print(f'License activation status - {"True" if result["license"]["activationStatus"] else "False"}')
    print(f'License owner - {result["license"]["userName"]}')
    print(f'License type - {"Personal" if result["license"]["type"] == 0 else "Company"}')
    print(f'Expiration date - {result["license"]["expirationDate"]}')

elif error == RadioErrors.INVALID_LICENSE:
    print("Invalid license key!")
else:
    print(f'Something unexpected happen while trying to login to the service (error code {error}).')
"use strict";

/******************************************************************************
 *
 * Radio Code Calculator API - WebApi interface usage example
 *
 * In this example we will verify our activation key status.
 *
 * Version      : v1.1.0
 * JS           : ES6
 * Dependencies : radio-code-calculator
 * Author       : Bartosz Wójcik (support@pelock.com)
 * Project      : https://www.pelock.com/products/radio-code-calculator
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/radio-code-calculator
 * @copyright Copyright (c) 2021-2023 PELock LLC
 * @license Apache-2.0
 *
/*****************************************************************************/

//
// include Radio Code Calculator API module
//
import { RadioCodeCalculator, RadioErrors, RadioModel, RadioModels } from "radio-code-calculator";

//
// create Radio Code Calculator API class instance (we are using our activation key)
//
let myRadioCodeCalculator = new RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD");

//
// login to the service
//
myRadioCodeCalculator.login().then((result) => {

    //
    // result[] array holds the information about the license
    //
    // result["license"]["activationStatus"] - True if license is active, False on invalid/expired keys
    // result["license"]["userName"] - user name/company name of the license owner
    // result["license"]["type"] - license type (0 - Personal License, 1 - Company License)
    // result["license"]["expirationDate"] - license expiration date (in YYYY-MM-DD format)
    //
    console.log("License activation status - " + (result["license"]["activationStatus"] ? "True" : "False") + "<br>");
    console.log("License owner - " + result["license"]["userName"]);
    console.log("License type - " + (result["license"]["type"] == 0 ? "Personal" : "Company") + "<br>");
    console.log("Expiration date - " + result["license"]["expirationDate"] + "<br>");

}).catch((error) => {

    if (error["error"] == RadioErrors.INVALID_LICENSE)
        console.log("Invalid license key!");
    else
        console.log(`Something unexpected happen while trying to login to the service (error code ${error}).`);
});

Masz pytania?

Jeśli masz jakieś pytania dotyczące Kalkulatora Kodów Do Radia oraz jego pakietów SDK, masz jakieś uwagi lub pytania dotyczące generowania kodów radiowych, albo coś jest niejasne, napisz do mnie, chętnie odpowiem na każde Twoje pytanie.