void WBSDBaseWindow::gotMessage(Message aMsg){ //qDebug() << "Got message:" << aMsg.getMsg().toHex(); emit transferMessage(aMsg); // if (queryQue.length()==0) // this->setCursor(Qt::ArrowCursor); }
void TConnectionProcessor::TOutboxQueue::transmissionLoop() { bool notificationSent = false; TPhysicalMailMessage mail_msg; TRequestMessage auth_msg; TStoredMailMessage storedMsg; bool auth_flag = false; while(!isCancelled() && fetchNextMessage(&storedMsg, &mail_msg, &auth_msg, &auth_flag)) { if(!notificationSent) { Processor.Sink->OnMessageSendingStart(); notificationSent = true; } if(auth_flag) { if(transferAuthMsg(storedMsg.from_key, auth_msg)) Outbox->remove_message(storedMsg); } else { if(transferMessage(storedMsg.from_key, mail_msg)) moveMsgToSentDB(storedMsg, mail_msg); } if(isCancelled()) break; fc::usleep(fc::milliseconds(250)); } if(notificationSent) Processor.Sink->OnMessageSendingEnd(); }
void WBSDBaseWindow::connectToMessages(QObject *aWindow){ connect(this ,SIGNAL(transferMessage(Message)),aWindow,SLOT(gotMessage(Message))); connect(this ,SIGNAL(newConnectionStatus(int,StringMessage)),aWindow,SLOT(connectionStatusChanged (int,StringMessage))); }
void Smarty::poll() { if (m_buttonPin < 255) if (digitalRead(m_buttonPin) == LOW && m_prevButtonState == HIGH) { m_prevButtonState = LOW; // fire a message to the combrick } else if (digitalRead(m_buttonPin) == HIGH && m_prevButtonState == LOW) { m_prevButtonState = HIGH; } // if ( m_radio.available(&pipe_num) ) { // m_radio.read(&m_rxMessage, CONSTANT_PAYLOAD_SIZE); if ((pipe_num = checkRx()) >= 0) { sendDebug("Received message from pipe %d", pipe_num); sendDebug("Opcode is %d", m_rxMessage.m_opcode); if (pipe_num == SMARTY_RX_PIPE && m_rxMessage.m_smartyID == m_config.m_smartyID) { //Serial.println("This command is for me"); switch (m_rxMessage.m_opcode) { case OPCODE_GENERIC_CMD: if (mp_genericCmdCb != NULL) mp_genericCmdCb(m_rxMessage.m_params[0], m_rxMessage.m_params + 1); break; case OPCODE_SET_ANALOG_CMD: if (mp_setAnalogCmdCb != NULL) { memcpy(pinCmds, m_rxMessage.m_params, 6); mp_setAnalogCmdCb(pinCmds); } else { sendDebug("set analog command for me"); memcpy(pinCmds, m_rxMessage.m_params, 6); for (int i = 0; i < NUM_HW_PINS; i++) { if (pinCmds[i].m_pinId < NUM_HW_PINS && m_pins[pinCmds[i].m_pinId].m_type == ANALOG_OUT) { analogWrite(m_pins[pinCmds[i].m_pinId].m_pinHwId, pinCmds[i].m_value); sendDebug("Found pin"); } } } break; case OPCODE_SET_DIGITAL_CMD: if (mp_setDigitalCmdCb != NULL) { memcpy(pinCmds, m_rxMessage.m_params, 6); mp_setDigitalCmdCb(pinCmds); } else { memcpy(pinCmds, m_rxMessage.m_params, 6); for (int i = 0; i < NUM_HW_PINS; i++) { if (pinCmds[i].m_pinId < NUM_HW_PINS && m_pins[pinCmds[i].m_pinId].m_type == ANALOG_OUT) digitalWrite(m_pins[pinCmds[i].m_pinId].m_pinHwId, pinCmds[i].m_value == 0 ? LOW : HIGH); } } break; case OPCODE_DC_MOTOR_CMD: if (mp_dcMotorCmdCb != NULL) mp_dcMotorCmdCb(m_rxMessage.m_params[1], m_rxMessage.m_params[2], m_rxMessage.m_params[3], m_rxMessage.m_params[4]); break; default: if (mp_defaultCmdCb != NULL) mp_defaultCmdCb(&m_rxMessage.m_opcode); break; } } else if (pipe_num == SMARTY_RX_PIPE) { // the message is intended for another smarty - transfer it (relay mode) // this should depend on a network map saved in the eeprom // design should allow unlimited hops transferMessage(); } else if (pipe_num == BROADCAST_RX_PIPE) { } } }