uint8_t RSTDIO_HandleStdioRxMessage(RAPP_MSG_Type type, uint8_t size, uint8_t *data, RNWK_ShortAddrType srcAddr, bool *handled, RPHY_PacketDesc *packet) { (void)srcAddr; (void)packet; switch(type) { case RAPP_MSG_TYPE_STDIN: /* <type><size><data */ *handled = TRUE; return RSTDIO_AddToQueue(RSTDIO_QUEUE_RX_IN, data, size); case RAPP_MSG_TYPE_STDOUT: /* <type><size><data */ *handled = TRUE; return RSTDIO_AddToQueue(RSTDIO_QUEUE_RX_OUT, data, size); case RAPP_MSG_TYPE_STDERR: /* <type><size><data */ *handled = TRUE; return RSTDIO_AddToQueue(RSTDIO_QUEUE_RX_ERR, data, size); default: break; } /* switch */ return ERR_OK; }
uint8_t RMT_ParseCommand(const unsigned char *cmd, bool *handled, const CLS1_StdIOType *io) { uint8_t res = ERR_OK; int32_t val; const unsigned char *p; if (UTIL1_strcmp((char*)cmd, (char*)CLS1_CMD_HELP)==0 || UTIL1_strcmp((char*)cmd, (char*)"remote help")==0) { RMT_PrintHelp(io); *handled = TRUE; } else if (UTIL1_strncmp((char*)cmd, "remote send val", sizeof("remote send val")-1)==0) { p = cmd+sizeof("remote send val"); if (UTIL1_xatoi(&p, &val)==ERR_OK && val>=0 && val<=4) { res = RSTDIO_AddToQueue(RSTDIO_QUEUE_TX_OUT, (unsigned char*)"test", 4); // RSTDIO_TxStdInSendChar('x'); // RADIO_setValueToSend(val); *handled = TRUE; } }/*else if (UTIL1_strcmp((char*)cmd, (char*)CLS1_CMD_STATUS)==0 || UTIL1_strcmp((char*)cmd, (char*)"radio status")==0) { RADIO_PrintStatus(io); *handled = TRUE; } else if (UTIL1_strcmp((char*)cmd, (char*)"radio reset")==0) { RADIO_AppStatus = RADIO_RESET_STATE; *handled = TRUE; } else if (UTIL1_strcmp((char*)cmd, (char*)"radio on")==0) { RADIO_isOn = TRUE; *handled = TRUE; } else if (UTIL1_strcmp((char*)cmd, (char*)"radio off")==0) { RADIO_isOn = FALSE; *handled = TRUE; } else if (UTIL1_strcmp((char*)cmd, (char*)"radio sniff on")==0) { RADIO_isSniffing = TRUE; *handled = TRUE; } else if (UTIL1_strcmp((char*)cmd, (char*)"radio sniff off")==0) { RADIO_isSniffing = FALSE; *handled = TRUE; } else if (UTIL1_strncmp((char*)cmd, (char*)"radio channel", sizeof("radio channel")-1)==0) { p = cmd+sizeof("radio channel"); if (UTIL1_xatoi(&p, &val)==ERR_OK && val>=0 && val<=15) { RADIO_SetChannel((uint8_t)val); *handled = TRUE; } else { CLS1_SendStr((unsigned char*)"Wrong argument, must be in the range 0..15\r\n", io->stdErr); res = ERR_FAILED; } } else if (UTIL1_strncmp((char*)cmd, "radio power", sizeof("radio power")-1)==0) { p = cmd+sizeof("radio power"); if (UTIL1_xatoi(&p, &val)==ERR_OK && val>=0 && val<=15) { RADIO_SetOutputPower((uint8_t)val); *handled = TRUE; } else { CLS1_SendStr((unsigned char*)"Wrong argument, must be in the range 0..15\r\n", io->stdErr); res = ERR_FAILED; } }*/ return res; }
/*! * \brief Radio StdErr: sends a character to the wireless communication channel. * \param ch Character to send */ static void RSTDIO_TxStdErr(uint8_t ch) { (void)RSTDIO_AddToQueue(RSTDIO_QUEUE_TX_ERR, &ch, sizeof(ch)); if (ch=='\n' || RSTDIO_NofInQueue(RSTDIO_QUEUE_TX_ERR)>RSTDIO_PAYLOAD_SIZE) { /* can send string over radio */ (void)FlushAndTxQueue(RSTDIO_QUEUE_TX_ERR, RAPP_MSG_TYPE_STDERR); } }
/*! * \brief Radio StdOut: sends a character to the wireless communication channel. * \param ch Character to send */ static void RSTDIO_TxStdOut(uint8_t ch) { (void)RSTDIO_AddToQueue(RSTDIO_QUEUE_TX_OUT, &ch, 1); if (ch=='\n' || RSTDIO_NofInQueue(RSTDIO_QUEUE_TX_OUT)>RSTDIO_PAYLOAD_SIZE) { /* can send string over radio */ (void)FlushAndTxQueue(RSTDIO_QUEUE_TX_OUT, RAPP_MSG_TYPE_STDOUT); } }