char *listDevice(struct threadInfo * ti) { if(ti->handlerArrays[HANDLER_ARRAY_ITEM].buffer == NULL || ti->handlerArrays[HANDLER_ARRAY_ITEM].buffer[0] == 0 || ti->handlerArrays[HANDLER_ARRAY_ITEM].size == 0) { // List all devices return(fetchDevice(1, QUERY_TYPE_PULL, ti)); } else { // List requested devices by category return(fetchDevice(2, QUERY_TYPE_PULL, ti)); } }
char *restoreDevice(struct threadInfo * ti) { if(ti->handlerArrays[HANDLER_ARRAY_ITEM].buffer == NULL || ti->handlerArrays[HANDLER_ARRAY_ITEM].buffer[0] == 0 || ti->handlerArrays[HANDLER_ARRAY_ITEM].size == 0) { replyPrepare(ERROR_SLIGHT, ERROR_CLASS_GENERAL, ERROR_CODE_GENERAL_PARAMETERNEEDED, ERROR_MESS_GENERAL_PARAMETERNEEDED, ti); return(ti->dataBuffer); } // Restore disposed device fetchDevice(9, QUERY_TYPE_PUSH, ti); return(fetchDevice(7, QUERY_TYPE_PUSH, ti)); }
bool EepromManager::applySettings() { if (!hasSettings()) return false; // start from a clean state deviceManager.setupUnconfiguredDevices(); logDebug("Applying settings"); // load the one chamber and one beer for now eptr_t pv = pointerOffset(chambers); tempControl.loadConstants(pv+offsetof(ChamberBlock, chamberSettings.cc)); tempControl.loadSettings(pv+offsetof(ChamberBlock, beer[0].cs)); logDebug("Applied settings"); #if BREWPI_TEMP_PROFILE profileControl.loadProfile(); #endif //BREWPI_TEMP_PROFILE DeviceConfig deviceConfig; for (uint8_t index = 0; fetchDevice(deviceConfig, index); index++) { if (deviceManager.isDeviceValid(deviceConfig, deviceConfig, index)) deviceManager.installDevice(deviceConfig); else { clear((uint8_t*)&deviceConfig, sizeof(deviceConfig)); eepromManager.storeDevice(deviceConfig, index); } } return true; }
char *notePullDevice(struct threadInfo * ti) { if(ti->handlerArrays[HANDLER_ARRAY_ITEM].buffer == NULL || ti->handlerArrays[HANDLER_ARRAY_ITEM].buffer[0] == 0 || ti->handlerArrays[HANDLER_ARRAY_ITEM].size == 0) { replyPrepare(ERROR_SLIGHT, ERROR_CLASS_GENERAL, ERROR_CODE_GENERAL_PARAMETERNEEDED, ERROR_MESS_GENERAL_PARAMETERNEEDED, ti); return(ti->dataBuffer); } // Pull notes from requested device return(fetchDevice(34, QUERY_TYPE_PULL, ti)); }
char *attachedDevicePeripheral(struct threadInfo * ti) { if((ti->handlerArrays[HANDLER_ARRAY_ITEM].buffer == NULL || ti->handlerArrays[HANDLER_ARRAY_ITEM].buffer[0] == 0 || ti->handlerArrays[HANDLER_ARRAY_ITEM].size == 0) && (ti->handlerArrays[HANDLER_ARRAY_PARAM].buffer == NULL || ti->handlerArrays[HANDLER_ARRAY_PARAM].buffer[0] == 0 || ti->handlerArrays[HANDLER_ARRAY_PARAM].size == 0)) { replyPrepare(ERROR_SLIGHT, ERROR_CLASS_GENERAL, ERROR_CODE_GENERAL_PARAMETERNEEDED, ERROR_MESS_GENERAL_PARAMETERNEEDED, ti); return(ti->dataBuffer); } if(ti->handlerArrays[HANDLER_ARRAY_ITEM].buffer == NULL || ti->handlerArrays[HANDLER_ARRAY_ITEM].buffer[0] == 0 || ti->handlerArrays[HANDLER_ARRAY_ITEM].size == 0) { // Get devices attached in peripheral return(fetchDevice(28, QUERY_TYPE_PULL, ti)); } else { // Get peripherals attached in device return(fetchDevice(29, QUERY_TYPE_PULL, ti)); } }
char *removeGlobalDeviceFromPeripheral(struct threadInfo * ti) { if(ti->handlerArrays[HANDLER_ARRAY_ITEM].buffer == NULL || ti->handlerArrays[HANDLER_ARRAY_ITEM].buffer[0] == 0 || ti->handlerArrays[HANDLER_ARRAY_ITEM].size == 0) { replyPrepare(ERROR_SLIGHT, ERROR_CLASS_GENERAL, ERROR_CODE_GENERAL_PARAMETERNEEDED, ERROR_MESS_GENERAL_PARAMETERNEEDED, ti); return(ti->dataBuffer); } // Remove device globally return(fetchDevice(31, QUERY_TYPE_PUSH, ti)); }
char *searchDevice(struct threadInfo * ti) { if(ti->handlerArrays[HANDLER_ARRAY_PARAM].buffer == NULL || ti->handlerArrays[HANDLER_ARRAY_PARAM].buffer[0] == 0 || ti->handlerArrays[HANDLER_ARRAY_PARAM].size == 0) { replyPrepare(ERROR_SLIGHT, ERROR_CLASS_GENERAL, ERROR_CODE_GENERAL_PARAMETERNEEDED, ERROR_MESS_GENERAL_PARAMETERNEEDED, ti); return(ti->dataBuffer); } // Search from devices return(fetchDevice(4, QUERY_TYPE_PULL, ti)); }
char *removeDevice(struct threadInfo * ti) { if(ti->handlerArrays[HANDLER_ARRAY_ITEM].buffer == NULL || ti->handlerArrays[HANDLER_ARRAY_ITEM].buffer[0] == 0 || ti->handlerArrays[HANDLER_ARRAY_ITEM].size == 0 || ti->handlerArrays[HANDLER_ARRAY_PARAM].buffer == NULL || ti->handlerArrays[HANDLER_ARRAY_PARAM].buffer[0] == 0 || ti->handlerArrays[HANDLER_ARRAY_PARAM].size == 0) { replyPrepare(ERROR_SLIGHT, ERROR_CLASS_GENERAL, ERROR_CODE_GENERAL_PARAMETERNEEDED, ERROR_MESS_GENERAL_PARAMETERNEEDED, ti); return(ti->dataBuffer); } // Remove device from requested machine return(fetchDevice(11, QUERY_TYPE_PUSH, ti)); }
char *attachDeviceToPeripheral(struct threadInfo * ti) { if(ti->handlerArrays[HANDLER_ARRAY_ITEM].buffer == NULL || ti->handlerArrays[HANDLER_ARRAY_ITEM].buffer[0] == 0 || ti->handlerArrays[HANDLER_ARRAY_ITEM].size == 0 || ti->handlerArrays[HANDLER_ARRAY_PARAM].buffer == NULL || ti->handlerArrays[HANDLER_ARRAY_PARAM].buffer[0] == 0 || ti->handlerArrays[HANDLER_ARRAY_PARAM].size == 0) { replyPrepare(ERROR_SLIGHT, ERROR_CLASS_GENERAL, ERROR_CODE_GENERAL_PARAMETERNEEDED, ERROR_MESS_GENERAL_PARAMETERNEEDED, ti); return(ti->dataBuffer); } // Attach device to requested peripheral return(fetchDevice(26, QUERY_TYPE_PUSH, ti)); }
char *cloneDeviceAttachmentsForMachine(struct threadInfo * ti) { if(ti->handlerArrays[HANDLER_ARRAY_ITEM].buffer == NULL || ti->handlerArrays[HANDLER_ARRAY_ITEM].buffer[0] == 0 || ti->handlerArrays[HANDLER_ARRAY_ITEM].size == 0 || ti->handlerArrays[HANDLER_ARRAY_DOMAIN].buffer == NULL || ti->handlerArrays[HANDLER_ARRAY_DOMAIN].buffer[0] == 0 || ti->handlerArrays[HANDLER_ARRAY_DOMAIN].size == 0 || ti->handlerArrays[HANDLER_ARRAY_PARAM].buffer == NULL || ti->handlerArrays[HANDLER_ARRAY_PARAM].buffer[0] == 0 || ti->handlerArrays[HANDLER_ARRAY_PARAM].size == 0) { replyPrepare(ERROR_SLIGHT, ERROR_CLASS_GENERAL, ERROR_CODE_GENERAL_PARAMETERNEEDED, ERROR_MESS_GENERAL_PARAMETERNEEDED, ti); return(ti->dataBuffer); } // Clone device attachments for machine return(fetchDevice(32, QUERY_TYPE_PUSH, ti)); }
char *newDevice(struct threadInfo * ti) { if(ti->handlerArrays[HANDLER_ARRAY_ITEM].buffer == NULL || ti->handlerArrays[HANDLER_ARRAY_ITEM].buffer[0] == 0 || ti->handlerArrays[HANDLER_ARRAY_ITEM].size == 0 || ti->handlerArrays[HANDLER_ARRAY_PARAM].buffer == NULL || ti->handlerArrays[HANDLER_ARRAY_PARAM].buffer[0] == 0 || ti->handlerArrays[HANDLER_ARRAY_PARAM].size == 0 || ti->handlerArrays[HANDLER_ARRAY_OPTION].buffer == NULL || ti->handlerArrays[HANDLER_ARRAY_OPTION].buffer[0] == 0 || ti->handlerArrays[HANDLER_ARRAY_OPTION].size == 0) { replyPrepare(ERROR_SLIGHT, ERROR_CLASS_GENERAL, ERROR_CODE_GENERAL_PARAMETERNEEDED, ERROR_MESS_GENERAL_PARAMETERNEEDED, ti); return(ti->dataBuffer); } // Create new device return(fetchDevice(5, QUERY_TYPE_ROUND, ti)); }