5.1. SMNetworkManager

Class to set printer’s network settings.

  • Constructor

    Name

    Contents

    init

    Creates the instance.

  • Method

    Name

    Contents

    load

    Gets the value specified from the printer.

    apply

    Set the specified value to the printer.

Supported Method for each models.

Model/Emulation

mC-Print2 mC-Print3 mC-Label3
StarPRNT StarPRNT StarPRNT

load

apply

5.1.1. init

Creates the instance.

  • Declaration

    public init?(portName: String)
    
  • Parameter

    Parameter

    Contents

    Type

    portName

    It is the same as the portName of the getPort method.

    String

  • Return value

    Contents

    Type

    SMNetworkManager object
    It returns nil when failed.

    init

5.1.2. load

Gets the value specified from the printer.

  • Declaration

    func load() throws -> SMNetworkSetting
    
  • Parameter

    None

  • Return value

    Contents

    Type

    Network Settings

    SMNetworkSetting

  • Exception

    Contents

    Type

    When port open fails
    When an incorrect portName is passed
    when a communication failure occurs

    StarIODeviceSettingException

  • Examples

    guard let portName = self.portNameTextField.text else { return }
    
    DispatchQueue.global().async {
    
        guard let starNetworkManager = SMNetworkManager(portName:portName) else { return }
    
        let starNetworkSetting : SMNetworkSetting
    
        do {
            starNetworkSetting = try starNetworkManager.load()
        } catch {
        }
    }
    

    Refer to StarIODeviceSettingSDK.

5.1.3. apply

Set the specified value to the printer.

Important

The printer is reset after this method was executed.

  • Declaration

    func apply(SMNetworkSetting) throws
    
  • Parameter

    Name

    Contents

    Type

    setting

    Network Setting Information

    SMNetworkSetting

  • Return value

    None

  • Exception

    Contents

    Type

    When port open fails
    When an incorrect portName is passed
    when a communication failure occurs

    StarIODeviceSettingException

  • Examples

    guard let portName = self.portNameTextField.text else { return }
    
    DispatchQueue.global().async {
    
        guard let starNetworkManager = SMNetworkManager(portName: portName) else { return }
        let starNetworkSetting = SMNetworkSetting()
    
        //Example) When setting to SteadyLanSetting to "Disable"
        starNetworkSetting.steadyLAN = .disable
    
        do {
            try starNetworkManager.apply(starNetworkSetting)
        } catch {
        }
    }
    

    Refer to StarIODeviceSettingSDK.