npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@yealink_dev/yealink-node-sdk-rcc

v1.0.1

Published

NodeJS SDK for Yealink Devices, Only for call control

Downloads

897

Readme

Yealink Node.js SDK

Table of Contents

Pre-requisite

  1. Node.js v8.x or later.

  2. On MacOS: xcode & python 2.7. By default, Python is installed on macOS but make sure correct version(2.7.x) is installed. Install Xcode from App store or download it from here.

  3. On Windows: Visual C++ Build Tools & Python 2.7. You can install all of these by following any of the below mentioned steps.

    3.1. During Node.js installation By ticking the checkbox when prompted during Node.js installation for Tools for Native modules, this installs both Visual C++ Build Tools & Python 2.7. Note This is prompted only for Windows platform. For other platforms like Linux or MAC, C++ compilation tools has to be installed separately as mentioned in other steps.

    3.2. Both Visual C++ Build Tools & Python 2.7 can also be installed using command npm install --global --production --add-python-to-path windows-build-tools. To know more about this tool, see this link.. Note For executing this command through Windows Command Prompt or Windows PowerShell, they should be ran in Administrator mode.

  4. All Platforms: node-gyp. You can install this using command npm install -g node-gyp. To know more about this, see this link

  5. For Electron.JS: If you are using asar packaging then you may need to unpack some of the resources used in this module. These resources are native library files i.e libyealinkusbsdk.dll, libyealinkusbsdk.dylib & libyealinkusbsdk.so, which is stored in a build\Release folder. By default latest electron builder will automatically unpack, but if it does not work then you can provide below option to your build process. To know more, see this link

"build": {
    "asarUnpack": ["node_modules/@yealink_dev/yealink-node-sdk-rcc"]
}

Installation

npm install @yealink_dev/yealink-node-sdk-rcc

Debugging and Logging

Below environment variables are defined for logging and debugging purpose. User can change the values as per preference.

Environment Variable | Value | Description --- | --- | --- YEALINKSDK_TRACE_LEVEL | error, warning, info(default), verbose | Log levels YEALINKSDK_RESOURCE_PATH | On Mac: ~/Library/Application Support/YealinkSdk/ On Windows: %appdata%/YealinkSdk | This determine the system path where logs and device related files are written.

API Reference

API doc is in html format. See doc folder inside installed module node_modules\@yealink_dev\yealink-node-sdk\dist\doc and open index.html.

Examples

For all examples, user should first register the app from yealink teams to get appID. User should pass this appID to initSdk in order to initialize the yealink module:

Simple button events example using javascript and plain promises

const sdk = require("@yealink_dev/yealink-node-sdk-rcc");
sdk.initSdk('test_App_Id').then((ylSdk) => { // test_App_Id is appId here
    ylSdk.RegEvent('attach', (deviceImpl) => {
        console.log('press any key on yealink device ' + deviceImpl.deviceName);
        
        deviceImpl.RegEvent('btnPress', (btnType, btnValue) => {
          console.log('new input from device is received: ', sdk.DeviceBtnType[btnType], btnValue);
        });
    });    
});

Simple button events example using typescript and plain promises

import { initSdk, DeviceBtnType } from '@yealink_dev/yealink-node-sdk-rcc';
initSdk('test_App_Id').then((ylSdk) => { // test_App_Id is appId here
    ylSdk.RegEvent('attach', (deviceImpl) => {
        console.log('press any key on yealink device ' + deviceImpl.deviceName);

        deviceImpl.RegEvent('btnPress', (btnType, btnValue) => {
          console.log('new input from device is received: ', DeviceBtnType[btnType], btnValue);
        });
    });   
});

For more examples, see src/simpletest

Multiple device management with typescript and async/await

import { initSdk } from '@yealink_dev/yealink-node-sdk-rcc';

(async () => {
    let ylSdk = await initSdk('test_App_Id'); // test_App_Id is appId here

    await ylSdk.firseScanForDeviceDoneAsync(); // Wait for all pre-attached devices to be scanned.

    const deviceInstanceList = ylSdk.getAttachedDevices();
    if (deviceInstanceList.length<2) {
        throw new Error('please make sure 2 yealink devices are attached');
    }

    const firstDevice = deviceInstanceList[0];
    await firstDevice.ringAsync();

    const secondDevice = deviceInstanceList[1];
    await secondDevice.ringAsync();

    // Dispose yealink sdk to enable node process to shutdown.
    await ylSdk.disposeAsync();
})();

Setup VSCode

The project includes config files for debugging typescript and C++ source files in Visual Studio Code via the C++ extension, for both Windows. The configuration files work without any modification, provided that you set up your environment first, by installing the necessary tools and defining some environment variable.

To debug a C++ file, open a typescript file referencing the C++ file and start the debugger (Running the debugger on C++ files directly won't work). Make sure the "Run"-dropdown at the top of the debugging-sidebar is set to "Current TS File - native code only (<your operating system>)"

Below, the setup steps for Windows.

Windows

You can more or less follow the instruction in the VSCode C++ extension guide. Then, you need to make sure all project pre-requisites are installed correctly, and finally set the following environment variables:

Environment Variable | Value | Description --- | --- | --- YEALINK_NODESDK_WIN_NODE_GYP_CACHE_PATH | eg. %appdata%\Local\node-gyp\Cache\12.16.3\include\node | Used by the C/C++ extension to resolve include paths YEALINK_NODESDK_WIN_CPP_COMPILER_PATH | eg. C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe | Used by the C/C++ extension to infer the path to the C++ standard library header files