code: public boolean writeCoil(int unitId, int ref, boolean state) throws ModbusException {
          checkTransaction();
          if (writeCoilRequest == null) {
              writeCoilRequest = new WriteCoilRequest();
          }
          writeCoilRequest.setUnitID(unitId);
          writeCoilRequest.setReference(ref);
          writeCoilRequest.setCoil(state);
          transaction.setRequest(writeCoilRequest);
          transaction.execute();
          return ((WriteCoilResponse) getAndCheckResponse()).getCoil();
      }
docs: Writes a coil state to the slave.
  
  @param unitId the slave unit id.
  @param ref    the offset of the coil to be written.
  @param state  the coil state to be written.
  
  @return the state of the coil as returned from the slave.
  
  @throws ModbusException if an I/O error, a slave exception or
  a transaction error occurs.