I am having problems with two Arduino Nano 33 IoTs. One Nano is situated near a low power peripheral. It scans for that peripheral then saves its profile in a series of tables and also advertises the same data. The second Nano scans for the first Nano and performs the same operation as the first (retrieve profile, save in tables, rebroadcast).
So, I can see that working for the most part but it seems that when I enable advertising without instantiating any services, characteristics or descriptors (all I do is advertise the localName and some manufacturing data, make the device "connectable" and call setAdvertisedServiceUuid() because apparently no advertising takes place if you do not call this function at some point - I guess?) I see 2 services, 3 characteristics and 3 descriptors. This is weird because I never did this in the code but to me it seems like these are either default attributes that are spit out by default from the ArduinoBLE library functionality or they are some kind of "leftover" junk that is from the NINA-W102 radio chip that was not cleared during the initial discovery of the peripheral.
My question here is are there default profile features that are "automatically" generated when using the ArduinoBLE library, and if so, are they overwritten by user-defined services, characteristics and descriptors? This is related to another problem I am having where I am seeing duplicated services, characteristics and descriptors along with duplicated UUIDs, and during debugging I discovered I can see profile features even when I never instantiated any. Thank you for any replies.
I think this is coming from the ArduinoBLE library, like some sort of default attributes pushed to every advertised device. When I advertise but don't instantiate any services, characteristics or descriptors I see 2 services, 3 characteristics and 3 descriptors:
11:43:44.655 -> Found dc:71:a2:f7:cc:72 'myPeripheral' 0xf009
11:43:44.655 -> Scanning stopped
11:43:44.655 -> Connecting ... connected at -67 dBm
11:43:45.218 -> Discovering services and their characteristics:
11:43:45.218 -> Number of services found: 2
11:43:45.218 -> Service 0: 0x1800
11:43:45.218 -> Number of characteristics found: 2
11:43:45.218 -> Characteristic 0: 0x2a00 0x2 readable! [8] 32 1 20 1 11 9 13 16
11:43:45.358 -> Number of descriptors found: 2
11:43:45.358 -> Descriptor 0: 0x2803 [5] 2 5 0 1 42
11:43:45.452 -> Descriptor 1: 0x2a01 [2] 31 24
11:43:45.593 -> Characteristic 1: 0x2a01 0x2 readable! [2] 31 24
11:43:45.687 -> Number of descriptors found: 0
11:43:45.687 -> Service 1: 0x1801
11:43:45.687 -> Number of characteristics found: 1
11:43:45.687 -> Characteristic 0: 0x2a05 0x20 not readable subscribable!
11:43:45.687 -> Number of descriptors found: 1
11:43:45.687 -> Descriptor 0: 0x2902 [2] 0 0
The strange thing is the peripheral I've already scanned has these data fields shown in the characteristics and descriptors, but the properties are not the same (they're shown as 0x2 for both "ghost" characteristics but in my peripheral they are 0xA and 0x2). So, what I suspect is the ArduinoBLE library is overlaying it's own generic services, characteristics and descriptors and its own characteristic properties but "stealing" whatever data buffer I had collected from the last device I scanned.
I would like to turn these default properties off and just advertise my own. Another workaround is to look for these ghosts and omit instantiating them as services since they're going to appear no matter what, but that sounds messy and there is also the unknown of reliably propagating the data and property qualities to these ghost attributes. I have looked in the Arduino library folder and I've noticed something in the GATT.cpp file that might be related. I am hoping someone from the GitHub team can read this and offer a suggestion. I am not pulling builds or recompiling, just using the library as-is (for this project, it's important that I "try" to use an off-the-shelf solution instead of writing custom code).
Klaus or anyone familiar with the ArduinoBLE library: Can you tell me a way to disable the duplicate descriptor generation? I managed to comment out sections of BLELocalCharacteristic.cpp and GATT.cpp that create duplicate services and characteristics; I also found a section that auto-generators descriptors with UUID = 0x2902. The problem now is all of my devices valid descriptors are being copied and nearly replicated (the data fields vary for some reason). Here is what it looks like:
The second set are the valid descriptors; the first ones are unexpected copies. This is is pretty much the last obstacle to getting this project working. I would appreciate your assistance.
Thanks in advance,
It turns out you can just comment out one small section from the GATT.cpp library file and the "ghost" attributes disappear. I commented out lines 72 through 75, which eliminates the creation of generic services and characteristics:
// **** 3 APR 2021
// **** COMMENTED OUT TO REMOVE DUPLICATE SERVICES, CHARACTERISTICS
/*
addService(_genericAccessService);
addService(_genericAttributeService);
*/
These were the only changes. The other items I was looking for appear to be connected to this. The version of ArduinoBLE library I am using is 1.2.0. I was thinking there was a switch or perhaps a specific prototype to avoid having these services added to the advertising list but I could not find anything.
I tried deleting UUIDs that I thought were problematic, such as 2902 or 1801 but that was not consistent; I then learned that some services and characteristics were tied to the deviceName() and appearance() so I tried getting rid of those but I still had duplicated descriptors. In the end all I could was modify the library - albeit ever so slightly. Still, it was our explicit wish to use the library "off-the-shelf" as that is part of the project requirements.