实例介绍
TestEngine API Overview
- Building a C/C Application
- Building a C# Application
- Building a Visual Basic Application
- Building a Delphi Application
- Example: Accessing the Persistent Store (BlueCore ICs)
- Example: ACL Data Transmission
The TestEngine API provides an interface for the development of PC based production test systems for testing BlueCore and other supported Qualcomm Bluetooth devices (see the release note for further details of IC support).
The API provides functions to perform a variety of operations including executing radio tests; reading/writing the Persistent Store; and executing a subset of HCI commands for performing operations such as creating a connection.
An application utilising the API can communicate with a device over a host transport (BCSP, H4, H4DS, H5, or USB) or a debug (SPI via USB or LPT, USBTRB or USBDBG) connection, depending on the supported transports for the IC type.
While some example code is included in on this overview page, some functions have example code within their own help page.
BlueCore ICs Function Support
For BlueCore ICs, some functions are not supported over SPI connections. These are summarised in the table below:
| Host | SPI | |
| BCCMD | Yes | Yes |
| DM | Yes | No |
| HCI | Yes | No |
| Persistent Store | Yes | Yes |
| Radiotest (and HQ) | Yes | Yes* |
| Reference Endpoint | Yes | Yes |
* HQ functions, and Radiotest functions that generate HQ traffic are only supported if the device firmware supports HQ over SPI.
NOTES:
Functions in the "Reference Endpoint" group are only supported for the BlueCore based Reference Endpoint product.
Functions in the "Audio" group are not supported for BlueCore ICs (audio tests are supported via BCCMD functions for BlueCore).
Functions in the "Radio Control" group are not supported for BlueCore ICs (use Radiotest functions for BlueCore).
In the "Persistent Store" group, only ps* functions are supported for BlueCore ICs.
For functions in the "Miscellaneous" group, see the help for each function for any restrictions based on IC or transport type.
Combo Digital Architecture ICs Function Support
For CDA ICs, support for some function groups is IC family dependent, as summarised in the table below:
| CSRC9xxx | CSRA681xx, QCC302x/3x, QCC512x | QCC304x, QCC514x and later ICs | |
| Audio | No | Yes | Yes |
| BCCMD | Yes | Yes | No |
| HCI | Yes | Yes | Yes |
| Persistent Store | Yes | Yes | Yes |
| Radiotest | Yes | Yes | No |
| Radio Control | No | No | Yes |
NOTES:
Functions in the "DM" group are not supported for CDA ICs.
Functions in the "Reference Endpoint" group are not supported for CDA ICs.
In the "Persistent Store group", only te* functions are supported for CDA ICs.
For functions in the "Miscellaneous" group, see the help for each function for any restrictions based on IC or transport type.
Using the TestEngine API
The TestEngine API can be used with a variety of programming languages. Your application will have to be executed in a folder containing all of the dynamic link libraries shipped with TrueTest.
Building a C/C Application
To build a C or C application you will need to include the TestEngine.h header file in your source files. Your application will also need to be linked against the TestEngine.lib import library. These files can be found in the following locations:
- Include files TestEngine.h in <BlueSuiteDir>\include
- Import library TestEngine.lib in <BlueSuiteDir>\lib
NOTE: The supplied import library is in COFF format. Borland users should use implib.exe to extract an OMF import library from TestEngine.dll.
Building a C# Application
To build a C# application you will need to add the TestEngineAPI.cs wrapper class file to your project. The unit file can be found in the following location:
- C# wrapper class file TestEngineAPI.cs in <BlueSuiteDir>\include\C#
To use the methods in the wrapper class, add the line "using TestEngineAPI;" to the top of the client code file. This gives access to the namespace containing the TestEngine wrapper class. The methods can then be called using the class name, e.g.: "TestEngine.initTestEngine()".
Building a Visual Basic Application
To build a Visual Basic application you will need to add the TestEngine function declarations module to your project. There are modules for three versions of Visual Basic which can be found in the following locations:
- VB6 function declarations TestEngineAPI.bas in <BlueSuiteDir>\include\VB6
- VB7 (.NET) function declarations TestEngineAPI.vb in <BlueSuiteDir>\include\VB7
- VB2005 (.NET) and later function declarations TestEngineAPI_05.vb in <BlueSuiteDir>\include\VB2005
Unsigned function arguments
Some of the functions in the TrueTest API take arguments of type uint16 or uint32 or return values of these types. These are unsigned 16/32 bit values. Whilst Visual Basic 2005(.NET) and later supports these types, Visual Basic versions 6 and 7(.NET) don't have any equivalent unsigned data types, so it is necessary to work around the limitation in code. The following paragraphs describe a work around for this issue, using the uint16 type as an example. The same principle can be applied for uint32 values, but with different values for the limits of 32 bit signed / unsigned types. The work around is not required for VB2005(.NET) and later as the new unsigned types (such as UShort and UInteger) are used in the VB2005 API file.Arguments of type uint16 are represented in Visual Basic as the signed 'Short' data type which is 16-bits wide but represents the values -32768 to 32767. This presents a problem when trying to pass values greater than 32767 to functions that take uint16 (Short) arguments as the Visual Basic compiler will not accept these values as being in the valid range for that type.
Unsigned values greater than 32767 must therefore be represented by their equivalent negative value. For example to pass the unsigned value 32768 as a Short, the value -32768 must be passed and to pass the unsigned value 65535, the value -1 must be passed.
The equivalent Short value can be found using a function similar to the one below. This will convert the desired unsigned value represented as a 32-bit Integer to the Short equivalent:
Function AsUShort(ByVal intVal As Integer) As Short
AsUShort = intVal Mod 32768
If intVal > 32767 Then
AsUShort = AsUShort Or &H8000S
End If
End Function
So applying the function yields the following results:
AsUShort(1) ==> 1 AsUShort(32767) ==> 32767 AsUShort(32768) ==> -32768 AsUShort(65535) ==> -1
A similar function is required to convert signed Short values from functions that return a uint16 as a Short.
An alternative exists for passing constants in to a function, which is to pass them as a hexadecimal literal suffixed with the Short character 'S' as below:
Const FOO As Short = &H8000S ' Represents 32768 as a Short
Building a Delphi Application
To build a Delphi application you will need to add the TestEngineAPI.pas function declarations unit to your project. The unit file can be found in the following location:
- Delphi function declarations TestEngineAPI.pas in <BlueSuiteDir>\include\Delphi
Example: Accessing the Persistent Store (BlueCore ICs)
Below is a sample C program showing how to use the functions in the API to write a value to the BlueCore persistent store.
#include "testengine.h"
#include <iostream>
const uint16 PSKEY_USR0 = 650;
int main(int argc, char** argv)
{
uint32 devHandle = openTestEngine(BCSP, "COM1", 115200, 5000, 0);
if(devHandle != 0)
{
std::cout << "Device Handle = " << devHandle << std::endl;
uint16 data[20];
data[0] = 123;
data[1] = 456;
if(psWrite(devHandle, PSKEY_USR0, PS_STORES_I, 2, data) == TE_OK)
{
std::cout << "Successfully wrote key" << std::endl;
}
else
{
std::cout << "Failed to write key" << std::endl;
closeTestEngine(devHandle);
return -1;
}
uint16 keySize;
psSize(devHandle, PSKEY_USR0, PS_STORES_IFR, &keySize);
data[0] = data[1] = 0;
if(psRead(devHandle, PSKEY_USR0, PS_STORES_IFR, 16, data, &keySize) == TE_OK)
{
std::cout << "data[0] = " << data[0] << std::endl
<< "data[1] = " << data[1] << std::endl;
}
else
{
std::cout << "Failed to read key" << std::endl;
closeTestEngine(devHandle);
return -1;
}
closeTestEngine(devHandle);
}
else
{
std::cout << "Failed to initialise device" << std::endl;
return -1;
}
return 0;
}
Example: ACL Data Transmission
The following example shows how to transmit a data file from one device to another.
#include "testengine.h"
#include <windows.h>
#include <iostream>
extern int DiffFiles(const char* file1, const char* file2);
int main(int argc, char** argv)
{
uint32 rxHandle = openTestEngine(BCSP, "com1", 115200, 5000, 0);
uint32 txHandle = openTestEngine(USB, "\\\\.\\csr0", 0, 5000, 1000);
if((txHandle != 0) && (rxHandle != 0))
{
hciSlave(rxHandle);
uint16 connHandle;
if(hciCreateConnectionNoInquiry(txHandle, 0x1be8f, 0x5b, 0x2, 0xcc18, 0, 0, 0, 1, &connHandle) != TE_OK)
{
std::cout << "Failed to connect to device" << std::endl;
closeTestEngine(txHandle);
closeTestEngine(rxHandle);
return -1;
}
std::cout << "Connection Handle = " << connHandle << std::endl;
hciResetAclState(rxHandle);
if(hciSendAclFile(txHandle, connHandle, "data.txt") == TE_OK)
{
int32 aclState;
do
{
Sleep(500);
if(hciGetAclState(rxHandle, &aclState) != TE_OK)
{
std::cout << "Error getting ACL state" << std::endl;
return -1;
}
} while(aclState != 3 && aclState != 4);
if(aclState == 3)
{
uint32 rxFileNameLength;
if(hciGetAclFileName(rxHandle, 0, &rxFileNameLength) != TE_OK)
{
std::cout << "Error getting ACL file name length" << std::endl;
return -1;
}
char* rxFileName = (char*)malloc((rxFileNameLength * sizeof(char)) 1);
if(hciGetAclFileName(rxHandle, rxFileName, &rxFileNameLength) != TE_OK)
{
std::cout << "Error getting ACL file name" << std::endl;
return -1;
}
std::cout << "File name = " << rxFileName << std::endl;
/*DiffFiles("data.txt", rxFileName);*/
free(rxFileName);
}
}
else
{
std::cout << "Failed to send file" << std::endl;
}
hciDisconnect(txHandle, connHandle);
closeTestEngine(txHandle);
closeTestEngine(rxHandle);
}
else
{
std::cout << "Failed to get handles to one or both devices" << std::endl;
return -1;
}
return 0;
}
标签: BlueSuite 3.3.10
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明


网友评论
我要评论