BLE application

I have a question concerning BLE. I am creating a service Location and Navigation Service. Just want to notify the long and lat coordinates.

First, I cannot read my LN feature

static gboolean handle_read_feature(
BluezGattCharacteristic1 *interface,
GDBusMethodInvocation *invocation,
GVariant *options,
gpointer user_data
)
{

//https://www.bt-test.systems/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.ln_feature.xml

guint32 feat = 0;
guint32 feat = (1 << 2);
g_print("%s called with feature : %s\n", __func__, feat);
GVariant *value = g_variant_new_uint32((const guint32)feat);
g_variant_ref_sink(value);
bluez_gatt_characteristic1_set_value(interface, value);
bluez_gatt_characteristic1_complete_read_value(interface, invocation, value);
g_variant_unref(value);

return TRUE;

}

Then when debugging, it says that “g_variant_new_fixed_array: array size 1 does not match given element_size 4.”

static void notify_long_lat(
BluezGattCharacteristic1 *gatt_characteristic_object,
guint32 longitude, guint32 latitude)
{
guint32 value_array = {longitude, latitude};
GVariant *value = g_variant_new_fixed_array(
G_VARIANT_TYPE_BYTESTRING, value_array, G_N_ELEMENTS(value_array), sizeof(value_array[0]));

bluez_gatt_characteristic1_set_value(gatt_characteristic_object, value);

}

Finally, do you know how am I supposed use the flag field as needed in this standard service. (file:///tmp/mozilla_mkasse0/LNS_V10.pdf)

Looks like a conflict between G_VARIANT_TYPE_BYTESTRING and sizeof(value_array[0]) which is 4 because it’s an array of guint32. Probably you need to use G_VARIANT_TYPE_GUINT32 or whatever the define is for that type.

My own code which works below. msg is a string.

    GVariant *value = g_variant_new_fixed_array(
        G_VARIANT_TYPE_BYTE, msg, strlen(msg), sizeof(guint8));

Please do know where I can find an example of an application with Location and Navigation using Bluez and DBus?
Methods in Dbus are quite difficult to implement for a beginner and it is not clear how for example to use WriteValue method in order to write in a characteristic. Any advices or links?

Could you tell me what is the best way to use GPS coordinates with Bluetooth.?Can I read the 3 coordinates one time or do I need to split into a characteristic for latitude, longitude and hAccuracy?

I tried to computed these lines
gdouble valueArray = {coor->latitude, coor->longitude, coor->hAccuracy};
GVariant *value = g_variant_new_fixed_array(
G_VARIANT_TYPE_BYTE, valueArray, G_N_ELEMENTS(valueArray), sizeof(valueArray[0]));

But I get this message:
g_variant_new_fixed_array: array size 1 does not match given element_size 8.

I think you have to get rid of the mismatch between G_VARIANT_TYPE_BYTE and your valueArray which is a double. Try G_VARIANT_TYPE_DOUBLE.

https://developer.gnome.org/glib/stable/glib-GVariantType.html