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