Hi everyone,
I'm trying to build a project for pico w that would advertise a custom service over GATT. I use https://github.com/bluekitchen/btstack/blob/master/example/gatt_counter.c as a reference.
Based on a reference example I've made advertisement data:
advertisementBuffer = [0x02, 0x01, 0x06,
0x0b, 0x09, UInt8(ascii: "L"), UInt8(ascii: "E"), UInt8(ascii: " "), UInt8(ascii: "C"), UInt8(ascii: "o"), UInt8(ascii: "u"), UInt8(ascii: "n"), UInt8(ascii: "t"), UInt8(ascii: "e"), UInt8(ascii: "r"),
0x03, 0x02, 0x10, 0xff]
gap_advertisements_set_data(UInt8(advertisementBuffer.count), &advertisementBuffer)
and also generated gatt profile data:
let profileData: [UInt8] = [
// ATT DB Version
1,
// 0x0001 PRIMARY_SERVICE-GAP_SERVICE
0x0a, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x28, 0x00, 0x18,
// 0x0002 CHARACTERISTIC-GAP_DEVICE_NAME - READ
0x0d, 0x00, 0x02, 0x00, 0x02, 0x00, 0x03, 0x28, 0x02, 0x03, 0x00, 0x00, 0x2a,
// 0x0003 VALUE CHARACTERISTIC-GAP_DEVICE_NAME - READ -'GATT Counter'
// READ_ANYBODY
0x14, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00, 0x2a, 0x47, 0x41, 0x54, 0x54, 0x20, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72,
// add Battery Service
// #import <battery_service.gatt> -- BEGIN
// Specification Type org.bluetooth.service.battery_service
// https://www.bluetooth.com/api/gatt/xmlfile?xmlFileName=org.bluetooth.service.battery_service.xml
// Battery Service 180F
// 0x0004 PRIMARY_SERVICE-ORG_BLUETOOTH_SERVICE_BATTERY_SERVICE
0x0a, 0x00, 0x02, 0x00, 0x04, 0x00, 0x00, 0x28, 0x0f, 0x18,
// 0x0005 CHARACTERISTIC-ORG_BLUETOOTH_CHARACTERISTIC_BATTERY_LEVEL - DYNAMIC | READ | NOTIFY
0x0d, 0x00, 0x02, 0x00, 0x05, 0x00, 0x03, 0x28, 0x12, 0x06, 0x00, 0x19, 0x2a,
// 0x0006 VALUE CHARACTERISTIC-ORG_BLUETOOTH_CHARACTERISTIC_BATTERY_LEVEL - DYNAMIC | READ | NOTIFY
// READ_ANYBODY
0x08, 0x00, 0x02, 0x01, 0x06, 0x00, 0x19, 0x2a,
// 0x0007 CLIENT_CHARACTERISTIC_CONFIGURATION
// READ_ANYBODY, WRITE_ANYBODY
0x0a, 0x00, 0x0e, 0x01, 0x07, 0x00, 0x02, 0x29, 0x00, 0x00,
// #import <battery_service.gatt> -- END
// 0x0008 PRIMARY_SERVICE-GATT_SERVICE
0x0a, 0x00, 0x02, 0x00, 0x08, 0x00, 0x00, 0x28, 0x01, 0x18,
// 0x0009 CHARACTERISTIC-GATT_DATABASE_HASH - READ
0x0d, 0x00, 0x02, 0x00, 0x09, 0x00, 0x03, 0x28, 0x02, 0x0a, 0x00, 0x2a, 0x2b,
// 0x000a VALUE CHARACTERISTIC-GATT_DATABASE_HASH - READ -''
// READ_ANYBODY
0x18, 0x00, 0x02, 0x00, 0x0a, 0x00, 0x2a, 0x2b, 0xdd, 0x90, 0x8b, 0xec, 0x00, 0x21, 0xa7, 0xf4, 0x4d, 0xfb, 0xf1, 0x6e, 0x3d, 0xa1, 0x6a, 0xe3,
// Counter Service
// 0x000b PRIMARY_SERVICE-0000FF10-0000-1000-8000-00805F9B34FB
0x18, 0x00, 0x02, 0x00, 0x0b, 0x00, 0x00, 0x28, 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x10, 0xff, 0x00, 0x00,
// Counter Characteristic, with read, write and notify
// 0x000c CHARACTERISTIC-0000FF11-0000-1000-8000-00805F9B34FB - READ | WRITE | NOTIFY | DYNAMIC
0x1b, 0x00, 0x02, 0x00, 0x0c, 0x00, 0x03, 0x28, 0x1a, 0x0d, 0x00, 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x11, 0xff, 0x00, 0x00,
// 0x000d VALUE CHARACTERISTIC-0000FF11-0000-1000-8000-00805F9B34FB - READ | WRITE | NOTIFY | DYNAMIC
// READ_ANYBODY, WRITE_ANYBODY
0x16, 0x00, 0x0a, 0x03, 0x0d, 0x00, 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x11, 0xff, 0x00, 0x00,
// 0x000e CLIENT_CHARACTERISTIC_CONFIGURATION
// READ_ANYBODY, WRITE_ANYBODY
0x0a, 0x00, 0x0e, 0x01, 0x0e, 0x00, 0x02, 0x29, 0x00, 0x00,
// END
0x00, 0x00,
]
att_server_init(profileData, ...
When I connect to my pico w using LightBlue app I see this
and the expected picture is this (based on the reference example)
I will post it in the next message since I can’t have more than one image here
Could anyone tell me what am I missing?