NodeJS SDK for Yealink Devices, Only for call control
npm install @yealink_dev/yealink-node-sdk-rccYealink Node.js SDK
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.
Visual C++ Build Tools & Python 2.7. You can install all of these by following any of the below mentioned steps.
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.
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.
node-gyp. You can install this using command npm install -g node-gyp. To know more about this, see this link
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
javascript
"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:
$3
`javascript
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);
});
});
});
`
$3
`typescript
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);
});
});
});
`
$3
$3
`typescript
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();
})();
``