Configure Location Beacon GPIO Port using iOS SDK

#1

Hello,

I need to know how to configure the GPIO port on the location beacon using the iOS SDK with Port 0 as an output and Port 1 as Input Pull Up. I cannot find any documentation on how to accomplish this. I suspect this configuration requires an UInt8. Please advise?

let setting = ESTSettingGPIOConfigPort0(value: ESTGPIOConfig(rawValue: <#T##UInt8#>))
let operation = ESTBeaconOperationGPIOConfigPort0(type: <#T##ESTSettingOperationType#>)

#2

ESTGPIOConfig is an old-school, Objective-C enum:

typedef NS_ENUM(uint8_t, ESTGPIOConfig)
{
    ESTGPIOConfigInputNoPull = 0x00,
    ESTGPIOConfigInputPullDown = 0x01,
    ESTGPIOConfigInputPullUp = 0x02,
    ESTGPIOConfigOutput = 0x03,
    ESTGPIOConfigUART = 0x04
};

But it should get translated nicely to a Swift enum, so you should be able to use it like ESTGPIOConfig.output or even .output with Swift’s type inference.

Here’s an example of how this might look in practice:

beacon.settings!.gpio.configPort0.writeValue(.output) { setting, error in
    if let error = error {
        NSLog("configPort0 writeValue error: \(error)")
    } else if let setting = setting {
        NSLog("configPort0 writeValue success: \(setting.getValue().rawValue)")
    }
}

beacon.settings!.gpio.configPort1.writeValue(.inputPullUp) { setting, error in
    if let error = error {
        NSLog("configPort1 writeValue error: \(error)")
    } else if let setting = setting {
        NSLog("configPort1 writeValue success: \(setting.getValue().rawValue)")
    }
}

Or using the BeaconOperation:

let setting = ESTSettingGPIOConfigPort0(value: .output)!
let operation = ESTBeaconOperationGPIOConfigPort0.writeOperation(withSetting: setting) { setting, error in
    if let error = error {
        NSLog("configPort0 writeOp error: \(error)")
    } else if let setting = setting {
        NSLog("configPort0 writeOp success: \(setting.getValue().rawValue)")
    }
}
beacon.settings!.performOperation(operation)