sandeepmistry / arduino-BLEPeripheral

An Arduino library for creating custom BLE peripherals with Nordic Semiconductor's nRF8001 or nR51822.
MIT License
462 stars 179 forks source link

Allow attribute table size to be changed via #define #171

Closed dsanders11 closed 6 years ago

dsanders11 commented 7 years ago

Minor change which makes it possible to easily increase the size of the GATT attribute table size. If you try to add too many attributes then the latest ones just seem to disappear and aren't usable, the solution being to increase the size of the attribute table (which will also require more RAM for the SoftDevice, and less for application).

If you increase just the size of the table then the BLE stack will silently fail to load because BLEPeripheral isn't checking the status code from sd_ble_enable, which would report NRF_ERROR_NO_MEM if it was checked. This can be fixed by tweaking the MEMORY values in the linker script for the particular board.

With this PR's change the quick and easy way to allow more attributes is to simply edit the linker script for the target board and then update boards.txt to include -DBLE_GATTS_ATTR_TAB_SIZE.

A larger change (can add to this PR if preferred) would be to check the status code of sd_ble_enable and in case of NRF_ERROR_NO_MEM and debug being enabled, send to serial the suggested start of RAM to use in the linker script (sd_ble_enable replaces the value in app_ram_base with the suggested value).

sandeepmistry commented 6 years ago

@dsanders11 thanks!