Using the FreeRTOS BLE Abstraction Layer Stack to create Tasks and Queues

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Using the FreeRTOS BLE Abstraction Layer Stack to create Tasks and Queues

ソリューションへジャンプ
2,529件の閲覧回数
tufantakak
Contributor II

I am developing a ble application based on the wireless uart freertos demo of the sdk_2.x_frdm kw 36 sdk. version 2.2.5.

I am trying to create a new task and  a queue  as described in the following document.

https://community.nxp.com/t5/NXP-Designs-Knowledge-Base/Using-the-QN908x-FreeRTOS-BLE-Abstraction-La...

After the task creation, the method call to Init the ble host stack returns gBleOsError_c.

if (Ble_Initialize(App_GenericCallback) != gBleSuccess_c)
{
panic(0,0,0,0);
return;
}

Disabling the newly created task makes the code initialize  the host stack.

Further debugging shows that   task creation mHost_TaskId = OSA_TaskCreate(OSA_TASK(Host_Task), NULL); fails in ble_host_tasks.c as mHost_TaskId is returned null.

Any help will be appreciated.

Thanks in advance

 

 

 

0 件の賞賛
返信
1 解決策
2,461件の閲覧回数
tufantakak
Contributor II

The problem was the serial baudrate.Changing the baudrate to 230400 in

wireless_uart.c BleApp_Init() as follows solved the problem.

(void)Serial_SetBaudRate(gAppSerMgrIf, (uint32_t)gUARTBaudRate230400_c);

 

元の投稿で解決策を見る

0 件の賞賛
返信
5 返答(返信)
2,462件の閲覧回数
tufantakak
Contributor II

The problem was the serial baudrate.Changing the baudrate to 230400 in

wireless_uart.c BleApp_Init() as follows solved the problem.

(void)Serial_SetBaudRate(gAppSerMgrIf, (uint32_t)gUARTBaudRate230400_c);

 

0 件の賞賛
返信
2,488件の閲覧回数
tufantakak
Contributor II

Hi again,

I previously marked your answer as solution but  as I proceeded  I figured out that  reducing the stack size for the newly created task did not solve my problem.

So I cancelled creating a new task.To explain briefly ,I get messages form android phone and try to send back particular responses through ble.

I receive data without any problem. I process the data form a response stream and send it as follows.

void SendMessage(uint8_t * pMsg,uint16_t msgLen){
     

         uint8_t *pBuffer = NULL;

        /* Allocate buffer for asynchronous write */
       pBuffer = MEM_BufferAlloc(msgLen);

if (pBuffer != NULL)
{
FLib_MemCpy(pBuffer , pMsg, (uint32_t)msgLen);


(void)Serial_AsyncWrite(gAppSerMgrIf, pBuffer, msgLen, Uart_RxCallBack, pBuffer);

}


}

Here are my callback functions

void Uart_RxCallBack(void *pData)
{
       uint16_t byteCount = 0;

(void)Serial_RxBufferByteCount(gAppSerMgrIf, &byteCount);

if (byteCount < mAppUartBufferSize)
{
/* Restart flush timer */
(void)TMR_StartLowPowerTimer(mUartStreamFlushTimerId,
gTmrLowPowerSingleShotMillisTimer_c,
mAppUartFlushIntervalInMs_c,
UartStreamFlushTimerCallback, NULL);
}
else
{
/* Post App Msg only one at a time */
if (!mAppDapaPending)
{
mAppDapaPending = TRUE;
(void)App_PostCallbackMessage(BleApp_FlushUartStream, NULL);
}
}
}

static void UartStreamFlushTimerCallback(void *pData)
{
if (!mAppDapaPending)
{
mAppDapaPending = TRUE;
(void)App_PostCallbackMessage(BleApp_FlushUartStream, NULL);
}
}

static void BleApp_FlushUartStream(void *pParam)
{
uint8_t *pMsg = NULL;
uint16_t bytesRead = 0;
uint8_t mPeerId = 0;
bool_t mValidDevices = FALSE;

/* Valid devices are in Running state */
for (mPeerId = 0; mPeerId < (uint8_t)gAppMaxConnections_c; mPeerId++)
{
if ((gInvalidDeviceId_c != maPeerInformation[mPeerId].deviceId) &&
(mAppRunning_c == maPeerInformation[mPeerId].appState))
{
mValidDevices = TRUE;
break;
}
}

if (mValidDevices)
{
/* Allocate buffer for GATT Write */
pMsg = MEM_BufferAlloc(mAppUartBufferSize);

if (pMsg != NULL)
{
/* Collect the data from the serial manager buffer */
if (Serial_Read(gAppSerMgrIf, pMsg, mAppUartBufferSize, &bytesRead) == gSerial_Success_c)
{
if (bytesRead != 0U)
{
/* Send data over the air */
BleApp_SendUartStream(pMsg, (uint8_t)bytesRead);
}
}

/* Free Buffer */
(void)MEM_BufferFree(pMsg);
}
}

mAppDapaPending = FALSE;
}

I simply send "pong" as an indicator of established ble link. I see first two letters of the pong message as "po" on serial terminal and immediately get
a hard fault.

These are my stack szie definitons
#define gHost_TaskStackSize_c 1200

#define gControllerTaskStackSize_c 1200

/* Defines Size for Serial Manager Task*/
#define gSerialTaskStackSize_c 500

/* Defines Size for TMR Task*/
#define gTmrTaskStackSize_c 600

I have been messing with nearly all available stack size combinations with no success.
Nay help will be appreciated.
Thanks

 

0 件の賞賛
返信
2,506件の閲覧回数
tufantakak
Contributor II

default host task stack size ( gHost_TaskStackSize_c in ble_host_task.h file) was 1500.reducing it solved the problem.

Thank you very much.

0 件の賞賛
返信
2,513件の閲覧回数
tufantakak
Contributor II

Thanks for the fast reponse.I will check and inform about the result.

0 件の賞賛
返信
2,518件の閲覧回数
nxf56274
NXP Employee
NXP Employee

Hi,

I guess the stack you allocate for the task is too large. Reduce it. If not, please debug into the function OSA_TaskCreate to make sense of why it returns NULL.

Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 days after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 件の賞賛
返信