2020-08-13 20:53:35 +02:00
|
|
|
#include "DeviceHandlerMessage.h"
|
|
|
|
#include "../objectmanager/ObjectManagerIF.h"
|
2016-06-15 23:48:41 +02:00
|
|
|
|
|
|
|
store_address_t DeviceHandlerMessage::getStoreAddress(
|
|
|
|
const CommandMessage* message) {
|
|
|
|
return store_address_t(message->getParameter2());
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t DeviceHandlerMessage::getDeviceCommandId(
|
|
|
|
const CommandMessage* message) {
|
|
|
|
return message->getParameter();
|
|
|
|
}
|
|
|
|
|
|
|
|
object_id_t DeviceHandlerMessage::getIoBoardObjectId(
|
|
|
|
const CommandMessage* message) {
|
|
|
|
return message->getParameter();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t DeviceHandlerMessage::getWiretappingMode(
|
|
|
|
const CommandMessage* message) {
|
|
|
|
return message->getParameter();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceHandlerMessage::setDeviceHandlerRawCommandMessage(
|
|
|
|
CommandMessage* message, store_address_t rawPacketStoreId) {
|
|
|
|
message->setCommand(CMD_RAW);
|
|
|
|
message->setParameter2(rawPacketStoreId.raw);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceHandlerMessage::setDeviceHandlerWiretappingMessage(
|
|
|
|
CommandMessage* message, uint8_t wiretappingMode) {
|
|
|
|
message->setCommand(CMD_WIRETAPPING);
|
|
|
|
message->setParameter(wiretappingMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceHandlerMessage::setDeviceHandlerSwitchIoBoardMessage(
|
|
|
|
CommandMessage* message, uint32_t ioBoardIdentifier) {
|
2020-10-01 11:01:52 +02:00
|
|
|
message->setCommand(CMD_SWITCH_ADDRESS);
|
2016-06-15 23:48:41 +02:00
|
|
|
message->setParameter(ioBoardIdentifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
object_id_t DeviceHandlerMessage::getDeviceObjectId(
|
|
|
|
const CommandMessage* message) {
|
|
|
|
return message->getParameter();
|
|
|
|
}
|
|
|
|
|
2019-08-28 14:50:24 +02:00
|
|
|
void DeviceHandlerMessage::setDeviceHandlerRawReplyMessage(
|
2016-06-15 23:48:41 +02:00
|
|
|
CommandMessage* message, object_id_t deviceObjectid,
|
|
|
|
store_address_t rawPacketStoreId, bool isCommand) {
|
|
|
|
if (isCommand) {
|
|
|
|
message->setCommand(REPLY_RAW_COMMAND);
|
|
|
|
} else {
|
|
|
|
message->setCommand(REPLY_RAW_REPLY);
|
|
|
|
}
|
|
|
|
message->setParameter(deviceObjectid);
|
|
|
|
message->setParameter2(rawPacketStoreId.raw);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceHandlerMessage::setDeviceHandlerDirectCommandReply(
|
|
|
|
CommandMessage* message, object_id_t deviceObjectid,
|
|
|
|
store_address_t commandParametersStoreId) {
|
|
|
|
message->setCommand(REPLY_DIRECT_COMMAND_DATA);
|
|
|
|
message->setParameter(deviceObjectid);
|
|
|
|
message->setParameter2(commandParametersStoreId.raw);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceHandlerMessage::clear(CommandMessage* message) {
|
|
|
|
switch (message->getCommand()) {
|
|
|
|
case CMD_RAW:
|
|
|
|
case REPLY_RAW_COMMAND:
|
|
|
|
case REPLY_RAW_REPLY:
|
|
|
|
case REPLY_DIRECT_COMMAND_DATA: {
|
|
|
|
StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>(
|
|
|
|
objects::IPC_STORE);
|
2020-10-01 11:01:52 +02:00
|
|
|
if (ipcStore != nullptr) {
|
2016-06-15 23:48:41 +02:00
|
|
|
ipcStore->deleteData(getStoreAddress(message));
|
|
|
|
}
|
|
|
|
}
|
2018-07-12 16:29:32 +02:00
|
|
|
/* NO BREAK falls through*/
|
2020-10-01 11:01:52 +02:00
|
|
|
case CMD_SWITCH_ADDRESS:
|
2016-06-15 23:48:41 +02:00
|
|
|
case CMD_WIRETAPPING:
|
|
|
|
message->setCommand(CommandMessage::CMD_NONE);
|
|
|
|
message->setParameter(0);
|
|
|
|
message->setParameter2(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|