0

I want to check that can we advertise simple string like "ttfgpV5hm8Z4mMlD" at the time of peripheral advertising I'm trying to pass this string into CBUUID string but whenever central scan for peripheral it gives an error like _C.CBUUID.CreationError.invalidString: I write down code which I use in peripheral and central.

Peripheral side :

Peripheral(configuration: configuration, advertisementData: [.localName("Test"), .servicesUUIDs("ttfgpV5hm8Z4mMlD")])

Central side :

let configuration = try! Configuration(services: [service], advertisement: "ttfgpV5hm8Z4mMlD")

please give me a guideline for how to pass a simple string at the time of scanning and advertising.

Larme
  • 24,190
  • 6
  • 51
  • 81
denish
  • 1
  • 1
  • I guess that advertisement needs to be a CBUUID (or a String representation of one), no? – Larme Feb 27 '19 at 11:42
  • "That said, only two of the keys are supported for peripheral manager objects: CBAdvertisementDataLocalNameKey and CBAdvertisementDataServiceUUIDsKey." Cf. https://stackoverflow.com/questions/15780267/the-advertisement-key-manufacturer-data-is-not-allowed-in-corebluetooth/17268059 – Larme Feb 27 '19 at 11:45

1 Answers1

0

CBUUIDs are UUIDs that contain hexadecimal digits - they aren't arbitrary strings. So unless your "simple string" only contains hex digits and you don't mind handling the hyphen separators, then you can't. What you can do is include the string as a value of a characteristic that is included by the service.

Tim
  • 68
  • 5