Exemple #1
0
/*
** ===================================================================
**     Method      :  CLS1_SendNum32u (component Shell)
**     Description :
**         Sends a 32bit unsigned number to the given I/O
**     Parameters  :
**         NAME            - DESCRIPTION
**         val             - number to print
**         io              - I/O callbacks to be used for printing.
**     Returns     : Nothing
** ===================================================================
*/
void CLS1_SendNum32u(uint32_t val, CLS1_StdIO_OutErr_FctType io)
{
  unsigned char buf[sizeof("1234567890")];

  UTIL1_Num32uToStr(buf, sizeof(buf), val);
  CLS1_SendStr(buf, io);
}
void loop(void) {
  static int cntr = 0;
  uint8_t buffer[32];

  if (device.available()) {
    // Should be a message for us now
    uint8_t buf[RH_APP_MAX_MESSAGE_LEN];
    uint8_t len = sizeof(buf);
    if (device.recv(buf, &len)) {
      LED2_Neg();
      cntr++;
      UTIL1_Num32uToStr(buffer, sizeof(buffer), cntr);
      UTIL1_strcat(buffer, sizeof(buffer), (const unsigned char*)": ");
      Serial_print((const char*)buffer);
      Serial_print("got request: ");
      Serial_println((char*)buf);
      // Send a reply
      uint8_t data[] = "And hello back to you";
      device.send(data, sizeof(data));
      device.waitPacketSent();
      Serial_println("Sent a reply");
    } else {
      Serial_println("recv failed");
    }
  }
}
Exemple #3
0
static uint8_t PrintStatus(CLS1_ConstStdIOType *io) {
  uint8_t buf[16];

  CLS1_SendStatusStr((unsigned char*)"neo", (const unsigned char*)"\r\n", io->stdOut);
  UTIL1_Num32uToStr(buf, sizeof(buf), NEO_NOF_X);
  UTIL1_strcat(buf, sizeof(buf), "\r\n");
  CLS1_SendStatusStr("  X", buf, io->stdOut);

  UTIL1_Num32uToStr(buf, sizeof(buf), NEO_NOF_Y);
  UTIL1_strcat(buf, sizeof(buf), "\r\n");
  CLS1_SendStatusStr("  Y", buf, io->stdOut);

  UTIL1_Num32uToStr(buf, sizeof(buf), NEO_NOF_PIXEL);
  UTIL1_strcat(buf, sizeof(buf), "\r\n");
  CLS1_SendStatusStr("  Pixels", buf, io->stdOut);
  return ERR_OK;
}