Setup SDK
Windows SDK Integration Guide
Overview
This guide is for developers who want to monetize Windows applications with PacketSDK.
Integrating the PacketSDK into an application is the first step toward earning revenue. Once you've integrated the SDK, you will start seeing devices data and revenue in PacketSDK Dashboard in 24 hours.
This document will walk you through the steps needed to be taken in order to properly integrate PacketSDK into your application.
Windows SDK Integration Guide
Prerequisites
Step 1: Apply for appkey.
'appkey' is an important way to track your earnings, please ensure it is set correctly in the subsequent integration steps.
Step 2: Download integration package.
Download the PacketSDK Windows integration package
packet_sdk_win-1.0.*.zipand unzip it.Once you unzip the package, you can see the following contents: packet_sdk_win-1.0.*.zip ├─── bin - Pre compiled binary executable program. ├─── C#(.NET) - Dynamic libraries required for C#(.net) integration. ├─── C++(MSVC&MT) - 32 bits or 64 bits dynamic and static libraries required for C++ or other languages integration. └─── demos - C#, C++, Python and GoLang integration demos.
Step 3: Choose an integration method that suits you.
Binary executable program integration
.NET(C#) native integration
C/C++ / Other programming language integration
Binary Executable Program Integration
Step 1: Find the binary executable program in the windows integration package.
Copy
packet_sdk.exefrom thebinfolder of integration package to your project.
Step 2: Launch executable program using appkey.
Supports two startup methods, starting with a regular executable program and starting with Windows services. The binary executable program packet_sdk.exe will automatically recognize it.
Regular executable program(as an independent process or subprocesss):
Windows services:
Step 3: Verify if integration is successful.
The log will be output in standard output by default, you can add startup parameters
-logfile=enableto enable local log file recording in step 2. After activation, the log file will be created in the same level directory of the program, and the old logs will be overwritten after each restart of the program.After step 2, if you receive
Server information obtained successfully.Connection established successfully.andThis device has been successfully certified.in the log, it indicates that you have successfully integrated Packet SDK.Once you've received
This device has been successfully certified.in the log, you will start seeing devices data and revenue in Packet SDK Dashboard in 24 hours.
.NET(C#) Integration
Step 1: Find the files required for C# integration in the windows integration package.
Copy
PacketSDK.dllandPacketSDK.xmlfrom the C#(.NET) directory to your project.Note
PacketSDK.xmlis used for Visual Studio to automatically fill in intelligent perception information and document descriptions, and it is not a runtime dependency.PacketSDK.dllis a runtime dependency that needs to be distributed in the same directory as the executable file.Targeting .NET Framework 4.5 / 9.0 (AnyCPU)
Step 2: Add references and import types contained in the namespace.
Add
PacketSDK.dllas a reference to your project.Import "PacketSDKAPI" namespace in your code.
Step 3: Call related API in your code.
Refer to the .NET API documentation at the bottom of this guide and directly call the relevant API.
See integration code example below and refer to
csharp_wpf_anycpuorcsharp_winform_anycpuintegration example indemosdirectory.
Step 4: Verify if integration is successful.
After call
PacketSDK.Start()API, if you receivePACKET_SDK_SERVER_OBTAINEDPACKET_SDK_SERVER_CONNECTEDandPACKET_SDK_SERVER_CERTIFIEDin the callback function you set, it indicates that you have successfully integrated Packet SDK into your application.Once you've received
PACKET_SDK_SERVER_CERTIFIEDin the callback function, you will start seeing devices data and revenue in Packet SDK Dashboard in 24 hours.
C/C++ / Other Languages Integration
Step 1: Select the appropriate machine word length and link type.
Machine word length
32 bits
64 bits
MSVC (Microsoft Visual C++ Compiler) Runtime
Since version 1.0.4, the MSVC runtime used by PacketSDK built in C++ only uses
MT.
Link Type

Note
When using static links, static libraries will be inserted into your program.
When using dynamic linking, you should distribute
packet_sdk.dllalong with your executable program.If your app is not developed in C++ language, or your C++ compiler is not MSVC, the link type can only be selected as Run time Dynamic Linking.
Step 2: Add the required resources to your project based on the parameters you have selected.
Static Link (MSVC C/C++)
Copy header file
packet_sdk.hfrom theC++(MSVC&MT)directory to your project.Copy static library
packet_sdk_static.libfromC++(MSVC&MT)/win32(win64)/static_linkdirectory to your project.Add the header file(packet_sdk.h) to your project and define the macro "PACKET_SDK_STATIC_LINK" in header file.
Inform the build system to link static library to executable program.
Visual Studio: Enter "PATH" in "Project - Attribute - Configure Properties - VC++ directory - Library directory". Enter "packet_sdk_static.lib" in "Project - Attribute - Configure Properties - Linker - Input - Additional dependencies".
Preprocessor directives: #pragma comment(lib, "/PATH/packet_sdk_static.lib")
cmake: link_directories(${PATH})
target_link_libraries(${PROJECT_NAME} "packet_sdk_static.lib" )
qmake(.pro): LIBS += -l/PATH/packet_sdk_static
Note
You can choose one of the methods to inform the build system based on the actual situation.
You should replace "PATH" with the actual path of the static library
packet_sdk_static.lib.
Load-time Dynamic Linking (MSVC C/C++)
Copy header file
packet_sdk.hfrom theC++(MSVC&MT)directory to your project.Copy export library
packet_sdk.libfromMSVC/win32(win64)/dynamic_linkdirectory to your project.Add the header file(.h) to your project and define the macro "PACKET_SDK_DYNAMIC_LINK" in header file.
Inform the build system to link export library to executable program.
Visual Studio: Enter "LIBPATH" in "Project - Attribute - Configure Properties - VC++ directory - Library directory". Enter "packet_sdk.lib" in "Project - Attribute - Configure Properties - Linker - Input - Additional dependencies".
Preprocessor directives: #pragma comment(lib, "/LIBPATH/packet_sdk.lib")
cmake: link_directories(${LIBPATH})
target_link_libraries(${PROJECT_NAME} "packet_sdk.lib")
qmake:LIBS += -l/LIBPATH/packet_sdk
Note
You can choose one of the methods to inform the build system based on the actual situation.
You should replace "PATH" with the actual path of the export library
packet_sdk.lib.
When distributing the app, packet_sdk.dll needs to be distributed together, and its location should be in the same level directory as the executable program.
Run-time Dynamic Linking (C++ MinGW Compiler / Other Languages)
When distributing the app, packet_sdk.dll needs to be distributed together, and its location should be in the same level directory as the executable program.
Step 3: Call the relevant api in your app's code.
Static Link (MSVC C/C++)
Refer to the C++ API documentation at the bottom of this guide and directly call the relevant API declaration in the header file.
See integration code example below and refer to
vc++_console_64bitindemosdirectory.
Load-time Dynamic Linking (MSVC C/C++)
Refer to the C++ API documentation at the bottom of this guide and directly call the relevant API declaration in the header file.
See integration code example below and refer to
qt_widget_32bitorqt_qml_32bitindemosdirectory.
Run-time Dynamic Linking (C++ MinGW Complier / Other Programming Languages)
Load dynamic libraries based on your programming language.
Parse symbols based on function signature based on your programming language.
Call the function according to the C++ API documentation below.
Step 4: Verify if integration is successful.
After call
packet_sdk_start()API, if receivePACKET_SDK_SERVER_OBTAINEDPACKET_SDK_SERVER_CONNECTEDandPACKET_SDK_SERVER_CERTIFIEDin the callback function you set, it indicates that you have successfully integrated Packet SDK into your application.Once you've received
PACKET_SDK_SERVER_CERTIFIEDin the callback function, you will start seeing devices data and revenue in Packet SDK Dashboard in 24 hours.
API documentation
API functions marked with
[**Required**]are essential for integration, while other APIs are optional.Setting the appkey should be done before starting the SDK call.
Once the callback function is successfully set, your callback function will immediately receive a PACKET_CLLACK_STSUCCESS
.NET (C#)
C/C++ API
Last updated