thx in advance!
Hello,
Using EZ430-rf2560
with sample acceleromter application for a project. For now, I'm
trying to turn BT on and make local device discoverable for phone
pairing. Debug session takes me to error handler function when script
is running. Code is based on accelerometer application explanation from
DEVELOPER'S GUIDE. IAR is running on a virtual windows. Please help.
I'm a noob at this so detailed solutions are greatly appreciated. The
following is my main script code.
int main(void)
{
sdk_start_scheduler(); /* Start OS scheduler */
// sdk_handle_init_sequence();
P1DIR=BIT0+BIT1;
UINT16 retval = sdk_bluetooth_on();
if (API_SUCCESS == retval)
{
UINT16 sdk_bt_power = SDK_BT_ON_IN_PROGRESS;
for(int z=0;z<20;z++)
{
P1OUT ^=BIT1;
}
}
/* Write Inquiry Scan mode (Interlaced scanning = 0x01) */
//UCHAR scan_type2=0x01;
//Interlaced scanning=0x01;
retval = BT_hci_write_inquiry_scan_type(0x01);
if (retval != API_SUCCESS) {
//sdk_display(SDK_MSG_AREA,(const UCHAR *)"Failed to set inquiry scan type\n", 0);
}
/* Change write Page Scan mode (Interlaced scanning = 0x01)*/
retval = BT_hci_write_page_scan_type(0x01);
if (retval != API_SUCCESS) {
// sdk_display(SDK_MSG_AREA,(const UCHAR *)"Failed to set page scan type\n", 0);
/* Make local device discoverable (Inquiry Scan & Page Scan enabled =0x03)*/
}
UCHAR scan_type=0x03;
retval = BT_hci_write_scan_enable( 0x03);
if (API_SUCCESS == retval)
{
UCHAR sdk_bt_visible = SDK_DISC_ON;
for(int z=0;z<20;z++)
{
P1OUT |=BIT0;
}
}
/* for(int i=5000;i>0;i--)
{
P1OUT ^=BIT0;
}*/
retval = BT_hci_inquiry(SDK_INQUIRY_LAP, SDK_INQUIRY_LEN,SDK_NUM_RESPONSES);
if (retval != API_SUCCESS)
{
for(int z=0;z<10;z++)
{
P1OUT ^=BIT0;
}
}
// sdk_display(SDK_MSG_AREA, (const UCHAR *), "Failed to initiate Inquiry\n", 0);
// sdk_print_message( "Error: failed to initiate INquiry \O");
else
{
//sdk_diplay( "Inquiry started...Wait for completion]n",0);
}
API_RESULT sdk_hci_event_indication_callback(UCHAR event_type, UCHAR * event_data, UCHAR event_datalen);
// {
/* Switch on the Event Code */
/* switch (event_type)
{
case HCI_INQUIRY_RESULT_EVENT:
hci_inquiry_result_event_handler(event_data);
break;
}
return API_SUCCESS;
}*/
UCHAR * bd_addr;
UCHAR page_scan_rep_mode;
UCHAR page_scan_mode;
UINT16 clock_offset;
retval = BT_hci_remote_name_request(bd_addr,page_scan_rep_mode,page_scan_mode,clock_offset);
if (retval != API_SUCCESS)
{
printf("Remote Name Request FAILED !! Error Code = 0x%04x\n",
retval);
}
for(;;)
{}
return 0; /* Should never reach here */
}