     }
 
     private func writeMatrixNow(withWriteResponse: Bool) {
+        guard
+            let peripheral = controller.peripheral,
+            peripheral.state == .connected,
+            let matrixCharacteristic = matrixCharacteristic
+        else {
+            return
+        }
         guard let currentMatrix = currentMatrix else { fatalError("Invalid matrix write request") }
         var matrixBytes = currentMatrix.matrixBytes
         guard currentMatrix.matrixBytes.count == 11 && !(withWriteResponse && isWaitingForWriteResponse) else { fatalError("Invalid matrix write request") }

        delegate?.nuimoController(self, didChangeConnectionState: connectionState, withError: error)
    }

    open override func willDiscoverServices() {
        super.willDiscoverServices()
        matrixWriter = nil
    }

    public func display(matrix: NuimoLEDMatrix, interval: TimeInterval, options: Int) {
        queue.async {
            self.matrixWriter?.write(matrix: matrix, interval: interval, options: options)
        }
    }


            // When the matrix write response is not retrieved within 500ms we assume the response to have timed out
            writeResponseTimeoutDispatchWorkItem?.cancel()
            writeResponseTimeoutDispatchWorkItem = DispatchWorkItem() { [weak self] in self?.didRetrieveMatrixWriteResponse() }
            controller.queue.asyncAfter(deadline: .now() + 0.5, execute: writeResponseTimeoutDispatchWorkItem!)
        }
    }

