var appearance_ = null;
var includeTxPowerLevel_ = false;
var serviceData_ = null;
+ var servicesData_ = null;
var manufacturerData_ = null;
Object.defineProperties(this, {
}
}
},
+ servicesData: {
+ enumerable: true,
+ get: function() {
+ return servicesData_;
+ },
+ set: function(v) {
+ if (T.isNull(v)) {
+ servicesData_ = v;
+ } else if (T.isArray(v)) {
+ var tmpArray = []
+ for (var i = 0; i < v.length; ++i) {
+ if (v[i] instanceof tizen.BluetoothLEServiceData) {
+ tmpArray.push(v[i]);
+ }
+ }
+ servicesData_ = tmpArray;
+ }
+ }
+ },
manufacturerData: {
enumerable: true,
get: function() {
return;
}
+ // servicesData
+ if (T.isNull(dict.servicesData) || T.isArray(dict.servicesData)) {
+ // additional validation is done in setter of BluetoothLEAdvertiseData.servicesData
+ o.servicesData = dict.servicesData;
+ }
+
// manufacturerData
if (
T.isNull(dict.manufacturerData) ||
const std::string kUuids = "uuids";
const std::string kSolicitationUuids = "solicitationuuids";
const std::string kServiceData = "serviceData";
+const std::string kServicesData = "servicesData";
class ParsedDataHolder {
public:
return {};
}
+ LoggerD("BluetoohtLEServiceData: %s : %s", uuid_str.get<std::string>().c_str(), data.get<std::string>().c_str());
return BluetoothLEServiceData{std::move(*uuid), data.get<std::string>()};
}
ScopeLogger();
const auto& service_data_obj = obj.get(kServiceData);
- if (service_data_obj.is<picojson::null>()) {
+ const auto& services_data_obj = obj.get(kServicesData);
+
+ if (service_data_obj.is<picojson::null>() && services_data_obj.is<picojson::null>()) {
+ LoggerD("Service data is null");
return true;
- } else if (!service_data_obj.is<picojson::object>()) {
- return false;
}
- /*
- * Currently, only advertising of a single service data object is supported
- * by the Web API. In the future, support for advertising arrays of those
- * may be added.
- *
- * TODO: if supported, parse here the whole array of service data instances.
- */
- auto service_data = BluetoothLEServiceData::Construct(service_data_obj);
- if (!service_data) {
- return false;
+ // check servicesData first and append services to a vector (higher priority)
+ if (!services_data_obj.is<picojson::null>() && services_data_obj.is<picojson::array>()) {
+ LoggerD("Parsing service data array");
+ for (auto single_service : services_data_obj.get<picojson::array>()) {
+ auto service_data = BluetoothLEServiceData::Construct(single_service);
+ if (!service_data) {
+ return false;
+ }
+ out->service_data_.emplace_back(std::move(*service_data));
+ }
+ return true;
+ } else if (!service_data_obj.is<picojson::null>() && service_data_obj.is<picojson::object>()) {
+ LoggerD("Parsing single service data");
+ auto service_data = BluetoothLEServiceData::Construct(service_data_obj);
+ if (!service_data) {
+ return false;
+ }
+ out->service_data_.emplace_back(std::move(*service_data));
+ return true;
}
-
- out->service_data_.emplace_back(std::move(*service_data));
- return true;
+ return false;
}
static bool ParseManufacturerData(const picojson::value& obj, BluetoothLEAdvertiseData* out) {
error_message =
"Failed to start advertising: only 16 bit values of BluetoothLEServiceData::uuid are "
"supported";
+ } else if (BT_ERROR_ALREADY_DONE == ret) { // in case of duplicated advertiser data report it with correct message
+ LogAndReportError(util::GetBluetoothError(BT_ERROR_INVALID_PARAMETER, "Duplicated advertiser data"), &out,
+ ("bt_adapter_le_set_advertising_device_name() failed with: %d (%s)", ret,
+ get_error_message(ret)));
+ return;
}
LogAndReportError(util::GetBluetoothError(ret, error_message), &out,