This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf52 experimental ble blinky using iOS

Hello,

I am writing an iOS code using Swift3 to connect an iOS10 device to nRF52 pca10040 and blink an LED. The nRFConnect on iOS can easily connect using the device name and discover advertised services and characteristics. I was able to write value to the LED characteristic through nRFConnect to make LED 3 turn on and off. I believe the input text is of type String as shown in the following image.

image description

I wrote code that can scan by device name, connect, and discover services and characteristics.

My questions is, what kind of data is being sent from the iOS device to the nRF52 to make the LED turn On or OFF? Is that string converted to Hex or Binary before its sent ?

This is a sample code of my turnOnLED method:

func turnOnLED(){
    guard let LEDCharacteristic = self.LEDCharacteristic else {
        debugPrint("No valid LED Characteristic")
        return
    }
    
    let value: Array<UInt8> = [8]
    let data = Data(bytes: value)
    self.peripheral?.writeValue(data, for: LEDCharacteristic, type: .withResponse)
}

Thanks in advance !

Related