void OM_ProccessOperation(OPERATION_HEADER_t* operation_header) { /* TESTING REGION */ //For testing purposes just send throw UART port HAL_UartPrint("PROCESSIG OPERATION >> TO:"); numWriteHEX(operation_header->destinationAddress); HAL_UartPrint("\t CODE:"); numWriteHEX(operation_header->opCode); HAL_UartPrint("\t ARGS:"); uint8_t length = getCommandArgsLength(&operation_header->opCode); for (uint8_t i = 0; i < length; i++) { numWriteHEX(*((uint8_t*)operation_header + sizeof(OPERATION_HEADER_t) + i)); HAL_UartWriteByte(' '); } HAL_UartPrint("\r\n"); if(operation_header->opCode == EXTENSION_OPCODE) return; /* END OF TESTING REGION */ if(operation_header->destinationAddress == 0) //MINE (INTERNAL) { handleCommand(operation_header, 0); //sourceAddress = 0x00 }else { Radio_AddMessageByReference(operation_header); } }
static void appTimerHandler(SYS_Timer_t *timer) { char hex[] = "0123456789abcdef"; if (APP_ADDR == 0) { appSendData(); (void)timer; } if (APP_ADDR == 1) { appTemperature = HAL_MeasureTemperature(); HAL_UartWriteByte('T'); HAL_UartWriteByte('e'); HAL_UartWriteByte('m'); HAL_UartWriteByte('p'); HAL_UartWriteByte(':'); HAL_UartWriteByte(' '); HAL_UartWriteByte(hex[((int)appTemperature >> 4) & 0x0f]); HAL_UartWriteByte(hex[(int)appTemperature & 0x0f]); HAL_UartWriteByte('\r'); HAL_UartWriteByte('\n'); }
static void appSendMessage(uint8_t *data, uint8_t size) { uint8_t cs = 0; HAL_UartWriteByte(0x10); HAL_UartWriteByte(0x02); for (uint8_t i = 0; i < size; i++) { if (data[i] == 0x10) { HAL_UartWriteByte(0x10); cs += 0x10; } HAL_UartWriteByte(data[i]); cs += data[i]; } HAL_UartWriteByte(0x10); HAL_UartWriteByte(0x03); cs += 0x10 + 0x02 + 0x10 + 0x03; HAL_UartWriteByte(cs); }