Yealink Node.js SDK
Node.js v8.x or later.
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.
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.
All Platforms: node-gyp. You can install this using command npm install -g node-gyp. To know more about this, see this link
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"]
}
npm install @yealink_dev/yealink-node-sdk-rcc
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 doc is in html format. See doc folder inside installed module node_modules\@yealink_dev\yealink-node-sdk\dist\doc and open index.html.
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:
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);
});
});
});
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);
});
});
});
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();
})();
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.
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 |
Generated using TypeDoc