浏览网络发现在宝岛台湾的一些网站有很多有趣而且质量高的博客,特意搬过来和大家一起分享学习下。
QCC512x 与QCC302X基于ADK6.X 的蓝牙系列设备信息修改,可以用BlueSuite3,当前安装的是BlueSuite 3.2.1 ,可以cd C:\Program Files (x86)\QTIL\BlueSuite 3.2.1 运用CMD 命令
cd C:\Program Files (x86)\QTIL\BlueSuite 3.2.1。
详见 ADK6.X configcmd 命令。 如果量产的话需要运用BlueSuite 库来写量产工具,可以参阅BlueSuite 安装路径下的文档,此处用TestEngine 的库运用C++语言程序来修改设备信息
1、开发环境设置
开发环境:C++(Microsoft Visual Studio)
头文件:TestEngine.h
库文件:TestEngine.lib
运行环境:Windows 系统,TestEngine.dll 相关DLL,为了使得工具能够运行,可以把TestEngine.dll 相关DLL所在文件夹路径:C:\Program Files (x86)\QTIL\BlueSuite 3.2.1,设置成Path环境变量,这样工具程序就可以动态调用DLL相关库运行了。
2、开发流程
打开Microsoft Visual Studio 集成开发环境,新建à Win32-> console application,输入Project名BT_Info_Mag,选择console application—>Empty project->Finish 确认。
添加 BT_Info_Mag.cpp,代码如下:
- #include "include\\testengine.h"
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- using namespace std;
- char _pskey_bdaddr_[] = "{0xff03,0x5B,0x02}";//蓝牙地址
- char _devicename_[] = ""QCC302X-Self_Left"";//蓝牙名字
- uint32 iHandle(0);
- uint16 maxLen(256);
- uint16 count(0);
- static const char* const CFG_DB_PARAM = "hyd.sdb:QCC512X_CONFIG";
- int main(int argc, char** argv){
- uint32 iHandle = 0;
- cout << "Trying to connect..." << endl;
- iHandle = openTestEngine(TRB, "1", 0, 5000, 0);
- //iHandle = openTestEngine(USBDBG, "1", 0, 5000, 0);
- if(iHandle != 0)
- {
- cout << "Connected!" << endl;
- // Perform all your testing here
- // Initialise the configuration cache
- int32 success = teConfigCacheInit(iHandle, CFG_DB_PARAM);
- // Read the configuration into the cache from the device
- uint16 unused = 0;
- if (success == TE_OK)
- {
- success = teConfigCacheRead(iHandle, NULL, unused);
- }
- else
- {
- cout << "teConfigCacheRead failed!" << endl;
- }
- // Write Bluetooth address
- if (success == TE_OK)
- {
- success = teConfigCacheWriteItem(iHandle, "bt15:PSKEY_BDADDR", _pskey_bdaddr_);
- if (success != TE_OK)
- {
- cout << "curator15:PSKEY_BDADDR returned error" << endl;
- }
- else
- {
- cout << "curator15:changed PSKEY_BDADDR, successful " << endl;
- }
- }
- // Write Friendly name
- {
- success = teConfigCacheWriteItem(iHandle, "bt15:PSKEY_DEVICE_NAME", _devicename_);
- if (success != TE_OK)
- {
- cout << "curator15:PSKEY_DEVICE_NAME returned error" << endl;
- }
- else
- {
- cout << "curator15:PSKEY_DEVICE_NAME successful " << endl;
- }
- }
- if (success == TE_OK)
- {
- success = teConfigCacheWrite(iHandle, NULL, unused);
- }
- {
- char value[1000];
- uint32 maxLen;
- success = teConfigCacheReadItem(iHandle, "bt15:PSKEY_BDADDR", value, &maxLen);
- if (success != TE_OK)
- {
- cout << "curator15:PSKEY_BDADDR failed" << endl;
- }
- else
- {
- printf("BT Add:%s",value);
- cout << "curator15:PSKEY_BDADDR successful " << endl;
- }
- }
- //////readout the Bluetooth Name
- if (success == TE_OK)
- {
- success = teConfigCacheRead(iHandle, NULL, unused);
- }
- {
- char value[1000];
- uint32 maxLen;
- success = teConfigCacheReadItem(iHandle, "bt15:PSKEY_DEVICE_NAME", value, &maxLen);
- if (success != TE_OK)
- {
- cout << "curator15:PSKEY_DEVICE_NAME failed" << endl;
- }
- else
- {
- printf("BT Name:%s",value);
- cout << "curator15:PSKEY_DEVICE_NAME successful " << endl;
- }
- }
- closeTestEngine(iHandle);
- }
- else
- {
- cout << "Failed to connect" << endl;
- }
- getch();
- }
然后把TestEngine.lib 添加进来,就可以编译通过