Thanks,
I have one more query related to HCITRANS layer. I have tried bluetooth communication using the API's of HCITRANS layer but the data is not receiving at another end.
Following code is implemented in the SPP demo application provided by blutopia stack. And new API's like “HciTestW” and “HciTestR” are added as command, so i execute it from command line.
1) AT Board 1:
At one board “HciTestW” is called and in which the “HCITR_COMOpen” and “HCITR_COMWrite” routines are called and get the expected return values.
2) At Board 2:
At board 2, the “HciTestR” is called in which the “HCITR_COMOpen” and “HCITR_COMProcess” routines are called and get the expected return values.
But at board 2 we are not getting the callback called, it may be not receiving the data from another board. Please suggest if any thing missing.
HCITRANS Layer Code Snippet:
unsigned int HCITransportID=0;
void BTPSAPI COMDataCallback( unsigned int HCITransportID, unsigned int DataLength, unsigned char *DataBuffer , unsigned long CallbackParameter)
{
Display(("Callbk called for open com port\r\n"));
Display(("\n%s ..\r\n", __func__ ));
Display(("\nReceived Data:: Len %d \r\n%s\r\n",DataLength, DataBuffer));
}
static int HciTestW(ParameterList_t *TempParam)
{
unsigned int ret_val = 0;
//char test_str[]={0x1A,0x00,0x41,0x00,0x09,0xEF,0x2D,'H','E','L','L','L','O',0x2E};//"HELLO";
char test_str[] = "Hello world\r\n";
HCI_COMMDriverInformation_t COMMDriverInformation;
Display(("\n%s ..\r\n", __func__ ));
BSC_Shutdown(BluetoothStackID);
if(HCITransportID!=0)
HCITR_COMClose(HCITransportID);
COMMDriverInformation.BaudRate = 115200;
COMMDriverInformation.COMDeviceName = NULL;
COMMDriverInformation.COMPortNumber = 1;
COMMDriverInformation.DriverInformationSize = sizeof(COMMDriverInformation);
COMMDriverInformation.InitializationDelay = 100;
COMMDriverInformation.Protocol = cpUART;
HCITransportID = HCITR_COMOpen(&COMMDriverInformation,COMDataCallback,3); //Maven
Display(("HCITR_COMOpenRT_VALUE=%d\r\n",HCITransportID));
ret_val=HCITR_COMWrite(HCITransportID, sizeof(test_str),test_str);
Display(("HCITR_COMWRITE_RT_VALUE=%d\r\n",ret_val));
}
static int HciTestR(ParameterList_t *TempParam)
{
unsigned int ret_val = 0;
HCI_COMMDriverInformation_t COMMDriverInformation;
Display(("\n%s ..\r\n", __func__ ));
BSC_Shutdown(BluetoothStackID);
if(HCITransportID!=0)
HCITR_COMClose(HCITransportID);
COMMDriverInformation.BaudRate = 115200;
COMMDriverInformation.COMDeviceName = NULL;
COMMDriverInformation.COMPortNumber = 1;
COMMDriverInformation.DriverInformationSize = sizeof(COMMDriverInformation);
COMMDriverInformation.InitializationDelay = 100;
COMMDriverInformation.Protocol = cpUART;
HCITransportID = HCITR_COMOpen(&COMMDriverInformation,COMDataCallback,3); //Maven
Display(("HCITR_COMOpenRT_VALUE=%d\r\n",HCITransportID));
HCITR_COMProcess(HCITransportID);
Display(("Waiting ..\r\n"));
}
In these API first Bluetooth stack is made shutdown( BSC_Shutdown(BluetoothStackID);). If we keep this Bluetooth stack initialized then we get error in “HCITR_COMOpen” as (-1).
Thanks & regards,
Ravi