主题中讨论的其他器件: MSP432E401Y、 MSP432P401R、 CC2564、 CC2564C、 MSP-EXP432E401Y、 CC2564MODNEM、
您好!
我将 MSP432E401Y 与 CC2564MODA 蓝牙模块搭配使用。 此时、我能够使用 Bluetopia 堆栈与模块进行通信。
我正在成功调用 InitializeApplication()函数,我们可以在 SPPDemo.c 文件(\samples\SPPDemo)中找到该函数。 初始化蓝牙堆栈后,我可以使用 OpenServer()打开 SPP 服务器,并定期调用 BTPS_ProcessScheduler()。 但此时、我的设备未进行广播、也不接受蓝牙连接。
运行代码时、调试控制台上会提供以下输出:
Openstack()。
蓝牙堆栈 ID:1.
器件芯片组:4.1
BTPS 版本 :4.0.3.0
项目类型 :6.
固件版本 :7.26
本地 BD_ADDR:CC:78:AB:7D:84:B8
本地设备名称():my_BTH_device
服务器已打开:1.
当我使用 GAP_Query_connectability 模式()、GAP_Query_discoverability 模式()和 GAP_Query_Pairability 模式()查询当前模式参数时,所有模式都可以。
有人能告诉我、我应该采取什么程序来检测任何异常吗?
此致
Nuno Dias
--------------------------------------
下面是一些代码片段、我是从 Bluetopia 栈示例中提取的:
int bluetooth_init (void)
int bluetooth_init(void) {
DEBUG_MSG("");
int Result;
BTPS_Initialization_t BTPS_Initialization;
HCI_DriverInformation_t HCI_DriverInformation;
HCI_HCILLConfiguration_t HCILLConfig;
HCI_Driver_Reconfigure_Data_t DriverReconfigureData;
/* Configure the hardware for its intended use. */
HAL_ConfigureHardware();
/* Configure the UART Parameters nd Initialize the Bluetooth Stack. */
HCI_DRIVER_SET_COMM_INFORMATION(&HCI_DriverInformation, 1, HAL_HCI_UART_MAX_BAUD_RATE, cpHCILL_RTS_CTS);
HCI_DriverInformation.DriverInformation.COMMDriverInformation.InitializationDelay = 100;
/* Set up the application callbacks. */
BTPS_Initialization.GetTickCountCallback = getTickCountCallback;
BTPS_Initialization.MessageOutputCallback = msgOutputCallback;
/* Initialize the application. */
Result = InitializeApplication(&HCI_DriverInformation, &BTPS_Initialization);
if (Result > 0) {
/* Save the Bluetooth Stack ID. */
BluetoothStackID = (unsigned int)Result;
Result = OpenServer(SPP_PORT_NUMBER_MINIMUM);
} else {
DisplayFunctionError("Initialize the application", Result);
}int 初始化应用程序(HCI_DriverInformation_t * HCI_DriverInformation、BTPS_Initialization_t * BTPS_Initialization)
/* The following function is used to initialize the application */
/* instance. This function should open the stack and prepare to */
/* execute commands based on user input. The first parameter passed */
/* to this function is the HCI Driver Information that will be used */
/* when opening the stack and the second parameter is used to pass */
/* parameters to BTPS_Init. This function returns the */
/* BluetoothStackID returned from BSC_Initialize on success or a */
/* negative error code (of the form APPLICATION_ERROR_XXX). */
int InitializeApplication(HCI_DriverInformation_t *HCI_DriverInformation, BTPS_Initialization_t *BTPS_Initialization)
{
int ret_val = APPLICATION_ERROR_UNABLE_TO_OPEN_STACK;
/* Initialize some defaults. */
SerialPortID = 0;
bthRole = BTH_ROLE_NONE;
NumberofValidResponses = 0;
/* Next, makes sure that the Driver Information passed appears to be */
/* semi-valid. */
if((HCI_DriverInformation) && (BTPS_Initialization))
{
/* Try to Open the stack and check if it was successful. */
if(!OpenStack(HCI_DriverInformation, BTPS_Initialization))
{
/* The stack was opened successfully. Now set some defaults. */
/* First, attempt to set the Device to be Connectable. */
ret_val = SetConnect();
/* Next, check to see if the Device was successfully made */
/* Connectable. */
if(!ret_val)
{
/* Now that the device is Connectable attempt to make it */
/* Discoverable. */
ret_val = SetDisc();
/* Next, check to see if the Device was successfully made */
/* Discoverable. */
if(!ret_val)
{
/* Now that the device is discoverable attempt to make it*/
/* pairable. */
ret_val = SetPairable();
if(!ret_val)
{
/* Attempt to register a HCI Event Callback. */
ret_val = HCI_Register_Event_Callback(BluetoothStackID, HCI_Event_Callback, (unsigned long)NULL);
if(ret_val > 0)
{
/* Assign a NULL BD_ADDR for comparison. */
ASSIGN_BD_ADDR(NullADDR, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
/* Save the maximum supported baud rate. */
MaxBaudRate = (DWord_t)(HCI_DriverInformation->DriverInformation.COMMDriverInformation.BaudRate);
/* Return success to the caller. */
ret_val = (int)BluetoothStackID;
}
else
DisplayFunctionError("HCI_Register_Event_Callback()", ret_val);
}
else
DisplayFunctionError("SetPairable", ret_val);
}
else
DisplayFunctionError("SetDisc", ret_val);
}
else
DisplayFunctionError("SetDisc", ret_val);
/* In some error occurred then close the stack. */
if(ret_val < 0)
{
/* Close the Bluetooth Stack. */
CloseStack();
}
}
else
{
/* There was an error while attempting to open the Stack. */
Display(("Unable to open the stack.\r\n"));
}
}
else
ret_val = APPLICATION_ERROR_INVALID_PARAMETERS;
return(ret_val);
}

