Esempio n. 1
0
/*!
 * \brief Flushes the given buffer/queue. The buffer will be sent over the radio.
 * \return Error code, ERR_OK for no error.
 */
static uint8_t FlushAndTxQueue(RSTDIO_QueueType queueType, RAPP_MSG_Type msgType) {
  unsigned char buf[RAPP_BUFFER_SIZE];
  uint8_t i;
  uint8_t res = ERR_OK;
  uint8_t *p, ch;
  
  p = RAPP_BUF_PAYLOAD_START(buf);
  i = 0;
  while (i<RAPP_PAYLOAD_SIZE) {
    ch = RSTDIO_ReceiveQueueChar(queueType);
    if (ch=='\0') { /* queue empty */
      break;
    }
    *p++ = ch;
    i++;
  }
  res = RAPP_PutPayload(buf, sizeof(buf), i, msgType, RSTDIO_dstAddr);
  if (res!=ERR_OK) {
    CLS1_ConstStdIOType *io = CLS1_GetStdio();

    io->stdErr('*');
    io->stdErr('F');
    io->stdErr('A');
    io->stdErr('I');
    io->stdErr('L');
    io->stdErr('*');
    io->stdErr('\n');
    return res;
  }
  return res;
}
Esempio n. 2
0
uint8_t RAPP_SendPayloadDataBlock(uint8_t *appPayload, uint8_t appPayloadSize, uint8_t msgType, RNWK_ShortAddrType dstAddr, RPHY_FlagsType flags) {
  uint8_t buf[RAPP_BUFFER_SIZE]; /* payload data buffer */
  int i;
  
  if (appPayloadSize>RAPP_PAYLOAD_SIZE) {
    return ERR_OVERFLOW; /* block too large for payload */
  }
  i = 0;
  while(i<appPayloadSize) {
    RAPP_BUF_PAYLOAD_START(buf)[i] = *appPayload;
    appPayload++; i++;
  }
  return RAPP_PutPayload(buf, sizeof(buf), appPayloadSize, (RAPP_MSG_Type)msgType, dstAddr, flags);
}