kw36 wireless uart and hci bb using the same uart

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

kw36 wireless uart and hci bb using the same uart

2,266 Views
shawn_123
Contributor I

hi, dear nxp engineer

    i am learning the KW36 freedom board.  i have debug and runned the demo: wireless uart .using the kinetis toolbox.

the app can receive the data send from the uart assisstant connect to KW36 using the USB cable attached with the board.

i also runned the hci bb and learned about that using uart assisstant send hci command. like 01 03 18 00.the uart assisstant will receive the data from the board. 

now i use wirelss_uart as the base project. and want to combine the function hci_bb poccess. when i made a contrast with the 2 project i found. 

1> hci bb demo had enable the macro: #define gUseHciTransportUpward_d  1  in app_preinclude.h.

2> the hci_tansport has the same source code in file hcit_serial_interface.c

so a add the macro "gUseHciTransportUpward_d" in NXP_WU demo. and meant to  implement like this :

when i send data in PC uart com: "0a 02 03"  i want the send "02 03" to the phone connected over air.

when i send data in PC uart com: "0b 01 03 18 00" the 01 03 18 00 will be send to hci controller use the API Hci_SendPacketToController(..) 

 

the detail code script like below in bold.

static void BleApp_FlushUartStream(void *pParam)
{
//.......................................................//ignore.
if (pMsg != NULL)
{
/* Collect the data from the serial manager buffer */
if ( Serial_Read( gAppSerMgrIf, pMsg, mAppUartBufferSize, &bytesRead) == gSerial_Success_c )
{
//if (bytesRead != 0)
if(bytesRead != 0 )
{
/* Send data over the air */
if( pMsg[0] == 0x0a) //add by yx.
{
BleApp_SendUartStream(pMsg, bytesRead);
}
else if(pMsg[0] == 0x0b)
{
//BleApp_SendUartStream(pMsg, bytesRead);
//uint8_t packet[20] = {0x00};
//FLib_MemCpy(packet, &pMsg[1], bytesRead-1);
//Hci_SendPacketToController(0x01,packet,3);
uint8_t packet[3] = {0x03,0x18,0x00};
Hci_SendPacketToController(0x01,packet,3);
}
}
}
/* Free Buffer */
MEM_BufferFree(pMsg);
}
}

i found the initialize in code in BleApp_init()

//SerialManager_Init();

/* Register Serial Manager interface */
Serial_InitInterface(&gAppSerMgrIf, APP_SERIAL_INTERFACE_TYPE, APP_SERIAL_INTERFACE_INSTANCE);

Serial_SetBaudRate(gAppSerMgrIf, gUARTBaudRate115200_c);

/* Install Controller Events Callback handler */
Serial_SetRxCallBack(gAppSerMgrIf, Uart_RxCallBack, NULL);

i aslo found the hcit_init() has mapped the same uart. 

/* Configure HCI Transport */
hcitConfigStruct_t hcitConfigStruct =
{
.interfaceType = gHcitInterfaceType_d,
.interfaceChannel = gHcitInterfaceNumber_d,
.interfaceBaudrate = gHcitInterfaceSpeed_d,
.transportInterface = (hciTransportInterface_t)Hci_SendPacketToController
};

return Hcit_Init(&hcitConfigStruct);

both mapped to APP_SERIAL_INTERFACE_TYPE APP_SERIAL_INTERFACE_INSTANCE

when i disable serial init in BleApp_init() then the Hci_SendPacketToController(..)  can send and receive controller event response. 

so how can i keep the uart function to receive data from pc uart assistant meanwhile can send data to controller use api like .Hci_SendPacketToController(..).

Labels (3)
0 Kudos
Reply
5 Replies

2,163 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello,

Sorry but it is not quite clear for me what you are trying to achieve. Do you want to use the HCI commands through Bluetooth LE? Could you please provide more details on your application ?

In the code you attached I see that you have commented the serial manager initialization

//SerialManager_Init();

Is there a specific reason why you disable it?

Are you sure that you want to use the HCI commands for your application ? Those are used for testing and certification mostly.

By any chance have you checked the FSCI commands? Maybe those are more helpful for you application, you can check more about this in the SDK documentation folder

Bluetooth Low Energy Host Stack FSCI Reference Manual

Bluetooth Low Energy Application Developer Guide

Also, something that I would like to clear , if you want to have two UARTs in the same pins , this is not possible . You might redirect the packets but you will need to use the same UART and initialization in case you want to have all the information in the same text console.

If you have any question, let me know.

Regards,

Estephania

0 Kudos
Reply

2,163 Views
shawn_123
Contributor I

you metioned "fsci" i have generally scanned the doc .i think the fsci have some similarity compared to hci. fsci can send some gap gatt gattdb relate command, i am not clear about the demo source code. if i want to use fsci command to set up connnect with a phone. what the main steps and code should i need to add. in the fsci bb.is there any other more detail or explicit demo to refer. thank you a lot!

0 Kudos
Reply

2,163 Views
estephania_mart
NXP TechSupport
NXP TechSupport

hello,

For further information about the HCI I would recommend you to check the Bluetooth LE core specifications as there are currently no HCI command to achieve in that way what you are trying to do , the only option here would be for you to create your own HCI command

I believe that the best way to achieve it is  the FSCI commands, in the SDK you can find a FSCI example as well and you can chekc the implementations on the HSDK which is also available in the SDK of the device.

Regards

Estephania

0 Kudos
Reply

2,163 Views
shawn_123
Contributor I

thank you a lot by the way is there any document on how to use hci command to set up connection with phone. and exchange data between.

do i need to add code like profile layers and gatt_db and some gap gatt relate funtions is there any demo can be inferred.

0 Kudos
Reply

2,163 Views
shawn_123
Contributor I

dear Estephania Martinez.

      i  just want to use the wireless_uart demo and can send some data over the air to the connected phone. and also can send raw data to packed as hci command to send to to controller layer and receive response from controller. i want the 2 function works in the one demo.

and i also used some other demo like heart rate sensor: when i enable the macro #define gUseHciTransportUpward_d  1  in hrs demo app_preinclude file . and add 2 test code below.

main_task()

{

//.......................................................

//......................................................ignore codes.

//.....................................................

//....................................................

#if !defined(MULTICORE_BLACKBOX)
/* BLE Host Stack Init */
if (Ble_Initialize(App_GenericCallback) != gBleSuccess_c)
{
panic(0,0,0,0);
return;
}
#endif /* MULTICORE_BLACKBOX */
}
//add test.
uint8_t packet[3] = {0x03,0x18,0x00};
Hci_SendPacketToController(0x01,packet,3);
PRINTF("RUN AT HERE THE PRINT..............\n\r");

/* Call application task */
App_Thread( param );
}

(the code in bold will send a test command to controller which works fine in hci bb.)

and update hrs demo hex to the kw36, it will not advertising when press the start advertising button.

only disable the macro the advertising will be recovered.

0 Kudos
Reply