-
Hi, I am having a really good time programming ESP32 BLE with Moddable, and I need a way to tell the client that the device name has changed, since LightBlue on iOS (indeed, iOS) uses the first GAP device name found and cached. I think that the service changed characteristic would be enough, but it is not clear (to me) how to do it in Moddable. Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Hi Daniele, The Moddable SDK does not have any special support for the service changed characteristic. You should, however, be able to deploy that characteristic exactly the same as any other GATT characteristic by using a GATT Service JSON file. Simply create a GATT Service JSON File that defines the Generic Attribute Service (UUID That said, I'm not actually sure what iOS's behavior is when you indicate a Service Change. It may or may not pick up the device name change — that's an implementation-specific detail. Please give this a shot and let me know how it goes. If you have trouble setting up the right GATT service, I can try putting together a little example later today. - Andy |
Beta Was this translation helpful? Give feedback.
-
Hi, I came up with this. I suspect that something is redundant and not-so-correct or elegant, but it is working so far, and useful. gap.json: {
"service": {
"uuid": "1800",
"characteristics": {
"device_name": {
"uuid": "2A00",
"maxBytes": 16,
"type": "String",
"permissions": "read",
"properties": "read",
"value": "My (new) device!"
},
"appearance": {
"uuid": "2A01",
"maxBytes": 2,
"type": "Uint16",
"permissions": "read",
"properties": "read",
"value": 1362
}
}
}
} gattrs.json: {
"service": {
"uuid": "1801",
"characteristics": {
"service_changed": {
"uuid": "2A05",
"type": "Array",
"maxBytes": 20,
"permissions": "read",
"properties": "indicate",
"value": ["0000", "FFFF"]
}
}
}
} This way, as soon as iOS connects to the device, it finds the service changed characteristic and modifies values in cache accordingly. |
Beta Was this translation helpful? Give feedback.
-
@scochet - this looks like something other developers would benefit from. It would be a great example for the Moddable SDK. Would you be willing to share a working example? A PR would be great. If it is easier for you to share in this discussion, that's fine too.
With a working example, it would be straightforward for @andycarle to take a look to see if he has any suggestions to offer. |
Beta Was this translation helpful? Give feedback.
Hi,
I came up with this. I suspect that something is redundant and not-so-correct or elegant, but it is working so far, and useful.
gap.json:
gattrs.json: