Part Number: LAUNCHXL-CC26X2R1
I'm using the zr_genericapp_CC26X2R1_LAUNCHXL_tirtos_ccs project provided by the sdk.
Instead of calling zclGenericApp_process_loop(); I'm running sendRadarDataTask();
I'm trying to send data received over uart with zcl_SendCommandEx which is working fine for 128 packages.
When sending package 129 - zcl_SendCommandEx the function returns 0 as status which means everything fine, BUT: The package isn't sent over zigbee
#include <assert.h>
#include <stdio.h>
#include <stdbool.h>
#include <strings.h>
#include "zstackmsg.h"
#include "zcl.h"
#include "uart_radaria_in.h"
#include "circular_buffer.h"
#include "slip.h"
#define GENERICAPP_ENDPOINT (8)
#define READ_IN_BUFFER_SIZE (512)
#define PACKET_SIZE (512)
// Uart Read Buffers
uint8_t readInBuffer[READ_IN_BUFFER_SIZE] = { };
uint8_t packet[PACKET_SIZE] = { };
circular_buffer cb = {};
bool dataComplete = false;
void uartReceive(uint8_t *data, size_t size)
{
int8_t ret = 0;
if (size > 0)
{
uint8_t c = data[0];
ret = cb_push_back(&cb, c);
if (ret != 0)
{
printf("Circular Buffer is full\n");
assert(ret != 0);
}
if (c == SLIP_END)
{
dataComplete = true;
}
}
}
void sendRadarDataTask()
{
char data;
ZStatus_t reply;
uint8_t sequenceNbr = 0;
uint16_t clusterID = 0;
uint8_t disableDefaultRsp = 1;
cb_init(&cb, readInBuffer, READ_IN_BUFFER_SIZE);
uart_radaria_in_init(uartReceive);
while (TRUE)
{
uart_read(&data, 1);
if (dataComplete)
{
dataComplete = false;
bzero(packet, PACKET_SIZE);
size_t packet_size = slip_read_packet(&cb, packet, PACKET_SIZE);
if (packet_size > 0)
{
afAddrType_t destAddr = { .addrMode = afAddr16Bit,
.panId =0xe9ca,
.addr = 0x0,
.endPoint = GENERICAPP_ENDPOINT };
reply = zcl_SendCommandEx(GENERICAPP_ENDPOINT, &destAddr, clusterID, zstackmsg_CmdIDs_AF_DATA_REQ,
FALSE, ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0, sequenceNbr++,
packet_size + 1, packet, TRUE);
printf("Zigbee sent done '%s'- reply was 0x%x\n", packet, reply);
}
}
}
}
I'm sending "hello0" til "hello129" as payload.
This is the debug output:
Zigbee sent done 'hello0'- reply was 0x0
SEND-Wait-Got reply-Returning 0
Zigbee sent done 'fhello1'- reply was 0x0
SEND-Wait-Got reply-Returning 0
Zigbee sent done 'fhello2'- reply was 0x0
SEND-Wait-Got reply-Returning 0
......
Zigbee sent done 'fhello127'- reply was 0x0
SEND-Wait-Got reply-Returning 0
Zigbee sent done 'fhello128'- reply was 0x0
SEND-Wait-Got reply-Returning 0
Zigbee sent done 'fhello129'- reply was 0x0
And this is the wireshark capture:

The other printouts are from the provided zstackapi.c (modified with printouts) :
/**
* Generic function to send a request message to the ZStack Thread
* and wait for a "default" response message.
*
* @param appServiceTaskId - Application Task ID
* @param cmdID - Command ID of the message
* @param pReq - Pointer to the request's structure
* @param msgSize - length of the message being sent
* @param pFnMatch - Function pointer to the response matching function
*
* @return zstack_ZStatusValues
*/
static zstack_ZStatusValues sendReqDefaultRsp(uint8_t appServiceTaskId,
zstack_CmdIDs cmdID, void *pReq,
int msgSize)
{
zstack_ZStatusValues status = zstack_ZStatusValues_ZMemError;
uint8_t msgStatus;
//Make sure allocate space enought for the msg, even
//if the message does not have payload
if(msgSize < sizeof(zstackmsg_genericReq_t))
{
msgSize = sizeof(zstackmsg_genericReq_t);
}
zstackmsg_genericReq_t *pMsg =
(zstackmsg_genericReq_t *)OsalPort_msgAllocate(msgSize);
// Make sure the allocation was successful
if(pMsg != NULL)
{
// Fill in the message header
pMsg->hdr.event = cmdID;
pMsg->hdr.status = 0;
pMsg->hdr.srcServiceTask = appServiceTaskId;
// Update the messges's request field
pMsg->pReq = pReq;
printf("SEND-");
// Send the message
msgStatus = OsalPort_msgSend( stackServiceTaskId, (uint8_t*) pMsg );
// Was the message sent successfully
if(msgStatus == OsalPort_SUCCESS)
{
bool gotRsp = false;
// Return status
zstackmsg_genericReq_t *pCmdStatus = NULL;
while(!gotRsp)
{
printf("Wait-");
// Wait for the response message
OsalPort_blockOnEvent(Task_self());
pCmdStatus = (zstackmsg_genericReq_t*)OsalPort_msgFindDequeue(appServiceTaskId, pMsg->hdr.event);
if(pCmdStatus)
{
gotRsp = true;
printf("Got reply-");
}
}
// setup return of
status = (zstack_ZStatusValues)pCmdStatus->hdr.status;
}
// pCmdStatus is the same as pMsg
OsalPort_msgDeallocate( (uint8_t*)pMsg);
}
printf("Returning %d\n", status);
// function status
return(status);
}
as you can see from the printout, regarding to code everything had worked.
Why the zigbee package isn't send? Did i need to flush something?