1

ANYONE WITH TROUBLE ON BLE & swift STUFF, this tutorial helped me a lot - https://www.udemy.com/iot-turn-a-light-on-with-your-iphone/learn/#/

I have successfully created a simple scanner view on my iphone6 that will scan the room for all Bluetooth devices and put their name in a table. When you click on that device you connect to the device and on the monitor i can see all of the services and even the characteristics of the device along with their UUID and all. I understand the basics of Bluetooth communication but i don't really understand UUID in terms of writing and weather or not it is the same for every device in the company, or brand or whatever. I was hoping someone could help explain this better to me and also hopefully help walk me through my bigger issue which is to write data to the bluetooth device.

I have a BLE shield for an arduino and i want to control the servo motor with my app. I have seen a few tutorials and some code on github that's got me this far but i can't seem to get the last part. Also I don't want to just copy what they have because I ultimately want to do this without an arduino and just a programmable chip and motor. below is the last part of my code that I am on, looking through the characteristics and printing them out for me to see

    func peripheral(peripheral: CBPeripheral, didDiscoverServices error: NSError?) {
    print("Service count  = \(peripheral.services!.count)")


    for service in peripheral.services!{
        print("Services = \(peripheral.services!)")

        let DemServices = service as CBService

        peripheral.discoverCharacteristics(nil, forService: DemServices)

        print("All that shit got coded")
    }



}

func peripheral(peripheral: CBPeripheral, didDiscoverCharacteristicsForService service: CBService, error: NSError?) {
    for characteristicz in service.characteristics!{
        print(characteristicz)
    }
}

So i want to write to the device and tell the motor connected to whatever pin to move to whatever degree based on what the app sends and if possible, a little more insight on how BLE devices work (UUID, BLE chips, Pins and how to manipulate things attached to them)

PLEASE help and thanks for trying!!

KellysOnTop23
  • 1,325
  • 2
  • 15
  • 34
  • 1
    UUID (service/characteristic) will be the same for same devices. It's like saying using the id that identify them. What to write and on which characteristic write them is up to each system, read their documentation. – Larme Nov 15 '15 at 21:31
  • that makes a little more sense @larme. but what about the pins aspect. I know which pins are available but how do i isolate them in code then send them data. Just looking at source isn't good way to learn for me. I learned everything in my spare time. any help? – KellysOnTop23 Nov 15 '15 at 22:57
  • It's really up to the BLE device documentation. Else, it's reverse engineering, and that's not that simple. – Larme Nov 15 '15 at 23:00

1 Answers1

0

There is an explanation about reading from, and writing to a BLE characteristic (emulating a serial port over Bluetooth with Tx and Rx) on this another question: SWIFT - BLE communications This may help you about the BLE stuff, but not with the particular hardware configuration you are dealing with (like I/O pins, etc.) That will be up to your particular hardware/firmware system.

Community
  • 1
  • 1
nbloqs
  • 3,152
  • 1
  • 28
  • 49