This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Only Sending 1 Byte

Hi

Hopefully a quick question. I want to send a set of bytes 'shtpData' between to routines but only one byte is being sent:

Sending 'unit8_t *dataPacket' of 5 bytes.

bool sendPacket(uint8_t channelNumber, uint8_t dataLength, uint8_t *dataPacket)
{

	uint8_t shtpData[MAX_PACKET_SIZE];

	shtpData[0] = dataLength & 0xFF;
	shtpData[1] = dataLength >> 8;
	shtpData[2] = channelNumber;
	shtpData[3] = sequenceNumber[channelNumber]++;
	for (uint8_t i = 0; i < dataLength; i++) {shtpData[i+4] = dataPacket[i];}

	ret_code_t err_code = srm_nrfx_twi_tx(shtpData, dataLength + 4);
	if (err_code != NRF_SUCCESS) {return false;}

	return true;

}

Receiver 'pData' is only the first byte.

uint32_t srm_nrfx_twi_tx (uint8_t *pData, uint32_t len)
{

	ret_code_t err_code;

	nrfx_twi_xfer_desc_t xfer_init;
    xfer_init.type = NRFX_TWI_XFER_TX;
    xfer_init.address = BNO080_ADDR_SH2_0;
    xfer_init.primary_length = len;
    xfer_init.p_primary_buf = pData;

    err_code = nrfx_twi_xfer(&m_twi, &xfer_init, 0);
    if(err_code != NRF_SUCCESS){return err_code;}

	return NRF_SUCCESS;
}

Any ideas?

Related