MTK elian(smartlink)在WIN32下的实现
先说明一下调试技巧:该程序需无线网卡实现功能,由于PC端有可能是多网卡的(有线网卡、无线网卡、虚拟网卡),所以在发包的时候数据包不一定会从无线网卡出,lib库应该也没处理多网卡的选择吧。所以在调试的时候需把除了无线网卡之外的网卡(有线网卡、虚拟网卡)都禁用,程序在执行的时候,会有大量数据通过网口,因此也可以通过Wireshark查看到网卡端口是否有数据出入,只要打开如下界面即可。
实现代码:
#include <stdio.h>
#include<string.h>
#include"elian.h"
#pragma comment(lib,"elian.lib")
int main(int argc,char*argv[])
{
unsignedchar target[]={0xff,0xff,0xff,0xff,0xff,0xff};
int ret =0;
unsignedint flag = ELIAN_SEND_V4;
void*handle = NULL;
unsignedchar authmode =0x04;
printf("Create elian Handle\n");
handle = elianNew(NULL,0, target, ELIAN_SEND_V4);
printf("Set TYPE_ID_AM\n");
ret = elianPut(handle, TYPE_ID_AM,(char*)&authmode,1);
printf("Set TYPE_ID_SSID ret=%d\n", ret);
ret = elianPut(handle, TYPE_ID_SSID,"Rookie", strlen("Rookie"));
printf("Set TYPE_ID_PWD ret=%d\n", ret);
ret = elianPut(handle, TYPE_ID_PWD,"123123123", strlen("123123123"));
printf("Set TYPE_ID_CUST ret=%d\n", ret);
ret = elianPut(handle, TYPE_ID_CUST,"aaaaaaa", strlen("aaaaaaa"));
printf("elianStart ret=%d\n", ret);
elianStart(handle);
getchar();
elianStop(handle);
elianDestroy(handle);
}
指定elian.lib库路径: