uint8_t wkpf_propagate_dirty_properties() {
	uint8_t wkpf_error_code;
	wuobject_t *dirty_wuobject;
	uint8_t dirty_property_number;

	while (wkpf_get_next_dirty_property(&dirty_wuobject, &dirty_property_number)) {
		// TODONR: comm
		// nvmcomm_poll(); // Process incoming messages
		wuobject_property_t *dirty_property = wkpf_get_property(dirty_wuobject, dirty_property_number);
		if (dirty_property->status & PROPERTY_STATUS_NEEDS_PUSH) {
			wkpf_error_code = wkpf_propagate_property(dirty_wuobject, dirty_property_number, &(dirty_property->value));
		} else { // PROPERTY_STATUS_NEEDS_PULL
			DEBUG_LOG(DBG_WKPF, "WKPF: (pull) requesting initial value for property %x at port %x\n", dirty_property_number, dirty_wuobject->port_number);
			wkpf_error_code = wkpf_pull_property(dirty_wuobject->port_number, dirty_property_number);
		}
		if (wkpf_error_code == WKPF_OK) {
			wkpf_propagating_dirty_property_succeeded(dirty_property);
		} else { // TODONR: need better retry mechanism
			DEBUG_LOG(DBG_WKPF, "WKPF: ------!!!------ Propagating property failed: port %x property %x error %x\n", dirty_wuobject->port_number, dirty_property_number, wkpf_error_code);
			wkpf_propagating_dirty_property_failed(dirty_property);
			return wkpf_error_code;
		}
	}
	return WKPF_OK;
}
Beispiel #2
0
uint8_t wkpf_propagate_dirty_properties() {
  uint8_t wkpf_error_code;
  uint8_t port_number;
  uint8_t property_number;
  int16_t value;
  uint8_t status;
  while(wkpf_get_next_dirty_property(&port_number, &property_number, &value, &status)) {
    nvmcomm_poll(); // Process incoming messages
    if (status & PROPERTY_STATUS_NEEDS_PUSH) {
      wkpf_error_code = wkpf_propagate_property(port_number, property_number, value);
    } else { // PROPERTY_STATUS_NEEDS_PULL
      DEBUGF_WKPF("WKPF: (pull) requesting initial value for property %x at port %x\n", property_number, port_number);
      wkpf_error_code = wkpf_pull_property(port_number, property_number);
    }
    if (wkpf_error_code != WKPF_OK) { // TODONR: need better retry mechanism
      DEBUGF_WKPF("WKPF: ------!!!------ Propagating property failed: port %x property %x error %x\n", port_number, property_number, wkpf_error_code);
      wkpf_propagating_dirty_property_failed(port_number, property_number, status);
      return wkpf_error_code;
    }
  }
  return WKPF_OK;
}