class BatteryService {
public:
/**
* @param[ref] _ble
* BLE object for the underlying controller.
* @param[in] level
* 8bit batterly level. Usually used to represent percentage of batterly charge remaining.
*/
BatteryService(BLE &_ble, uint8_t level = 100) :
ble(_ble),
batteryLevel(level),
batteryLevelCharacteristic(GattCharacteristic::UUID_BATTERY_LEVEL_CHAR, &batteryLevel, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) {
GattCharacteristic *charTable[] = {&batteryLevelCharacteristic};
GattService batteryService(GattService::UUID_BATTERY_SERVICE, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
ble.addService(batteryService);
}
/**
* @brief Update the battery level with a new value. Valid values range from
* 0..100. Anything outside this range will be ignored.
*
* @param newLevel
* update to battery level.
*/
void updateBatteryLevel(uint8_t newLevel) {
batteryLevel = newLevel;
ble.gattServer().write(batteryLevelCharacteristic.getValueHandle(), &batteryLevel, 1);
}
This code is the BatteryService.h from mbed.
I don't know what it is.
from line 11 to 20(looks like creator)
Is it creator? then what means
" : " (after BatteryService(BLE &_ble, uint8_t level = 100) )
I can't understand this part.