Exemplo n.º 1
0
/* This function sets the characteristic value specified by the given
   name to the value passed to the function. */
void circuit::setCharacteristic (const std::string &n, nr_double_t val) {
  auto it = charac.find(n);
  if (it != charac.end())
    (*it).second.setValue (val);
  else
    addCharacteristic (n, val);
}
Exemplo n.º 2
0
	// Constructor sets name, allocate characteristic, sets UUID, and sets default value.
	BatteryService(): GenericService() {
		setUUID(UUID(BLE_UUID_BATTERY_SERVICE));
		setName(BLE_SERVICE_BATTERY);

		_characteristic = new Characteristic<uint8_t>();
		addCharacteristic(_characteristic);

		_characteristic->setUUID(UUID(BLE_UUID_BATTERY_LEVEL_CHAR));
		_characteristic->setName(BLE_CHAR_BATTERY);
		_characteristic->setDefaultValue(100);
	}
void IndoorLocalizationService::addScanControlCharacteristic() {
	_scanControlCharac = new Characteristic<uint8_t>();
	addCharacteristic(_scanControlCharac);

	_scanControlCharac->setUUID(UUID(getUUID(), SCAN_CONTROL_UUID));
	_scanControlCharac->setName(BLE_CHAR_SCAN_CONTROL);
	_scanControlCharac->setDefaultValue(255);
	_scanControlCharac->setWritable(true);
	_scanControlCharac->onWrite([&](const uint8_t accessLevel, const uint8_t& value, uint16_t length) -> void {
		CommandHandler::getInstance().handleCommand(CMD_SCAN_DEVICES, (buffer_ptr_t)&value, 1);
	});
}
void IndoorLocalizationService::addRssiCharacteristic() {
	_rssiCharac = new Characteristic<int8_t>();
	addCharacteristic(_rssiCharac);

	_rssiCharac->setUUID(UUID(getUUID(), RSSI_UUID)); //! there is no BLE_UUID for rssi level(?)
	_rssiCharac->setName(BLE_CHAR_RSSI);
	_rssiCharac->setDefaultValue(1);
	_rssiCharac->setNotifies(true);
#ifdef PWM_ON_RSSI
	_averageRssi = -90; // Start with something..
#endif
}
void IndoorLocalizationService::addTrackedDeviceListCharacteristic() {

	MasterBuffer& mb = MasterBuffer::getInstance();
	buffer_ptr_t buffer = NULL;
	uint16_t maxLength = 0;
	mb.getBuffer(buffer, maxLength);

	_trackedDeviceListCharac = new Characteristic<buffer_ptr_t>();
	addCharacteristic(_trackedDeviceListCharac);

	_trackedDeviceListCharac->setUUID(UUID(getUUID(), TRACKED_DEVICE_LIST_UUID));
	_trackedDeviceListCharac->setName(BLE_CHAR_TRACK_LIST);
	_trackedDeviceListCharac->setWritable(false);
	_trackedDeviceListCharac->setNotifies(false);
	_trackedDeviceListCharac->setValue(buffer);
	_trackedDeviceListCharac->setMaxGattValueLength(maxLength);
	_trackedDeviceListCharac->setValueLength(0);
}
void IndoorLocalizationService::addTrackedDeviceCharacteristic() {

	MasterBuffer& mb = MasterBuffer::getInstance();
	buffer_ptr_t buffer = NULL;
	uint16_t maxLength = 0;
	mb.getBuffer(buffer, maxLength);

	_trackedDeviceCharac = new Characteristic<buffer_ptr_t>();
	addCharacteristic(_trackedDeviceCharac);

	_trackedDeviceCharac->setUUID(UUID(getUUID(), TRACKED_DEVICE_UUID));
	_trackedDeviceCharac->setName(BLE_CHAR_TRACK);
	_trackedDeviceCharac->setWritable(true);
	_trackedDeviceCharac->setNotifies(false);

	_trackedDeviceCharac->setValue(buffer);
	_trackedDeviceCharac->setMaxGattValueLength(maxLength);
	_trackedDeviceCharac->setValueLength(0);

	_trackedDeviceCharac->onWrite([&](const uint8_t accessLevel, const buffer_ptr_t& value, uint16_t length) -> void {
		Tracker::getInstance().handleTrackedDeviceCommand(_trackedDeviceCharac->getValue(),
				_trackedDeviceCharac->getValueLength());
	});
}
Exemplo n.º 7
0
/**
 * @brief Create a new BLE Characteristic associated with this service.
 * @param [in] uuid - The UUID of the characteristic.
 * @param [in] properties - The properties of the characteristic.
 * @return The new BLE characteristic.
 */
BLECharacteristic* BLEService::createCharacteristic(BLEUUID uuid, uint32_t properties) {
	BLECharacteristic *pCharacteristic = new BLECharacteristic(uuid, properties);
	addCharacteristic(pCharacteristic);
	return pCharacteristic;
} // createCharacteristic
Exemplo n.º 8
0
/*!
  Sets the list of characteristics to \a characteristics.
  Only valid characteristics are considered.
  \sa addCharacteristic()
 */
void QLowEnergyServiceData::setCharacteristics(const QList<QLowEnergyCharacteristicData> &characteristics)
{
    d->characteristics.clear();
    foreach (const QLowEnergyCharacteristicData &cd, characteristics)
        addCharacteristic(cd);
}