Git Product home page Git Product logo

Comments (5)

weliem avatar weliem commented on July 17, 2024 1

I just committed a fix for this issue

from bluez_inc.

lizziemac avatar lizziemac commented on July 17, 2024

I believe you'd want to make the characteristic part of a service that isn't advertised. For example, using a modified peripheral.c:

        // Setup advertisement
        GPtrArray *adv_service_uuids = g_ptr_array_new();
        g_ptr_array_add(adv_service_uuids, HTS_ADVERTISING_SERVICE_UUID); // Make a service specifically for advertising

        advertisement = binc_advertisement_create();
        binc_advertisement_set_local_name(advertisement, "BINC");
        binc_advertisement_set_services(advertisement, adv_service_uuids); // only add that service to the advertising services
        g_ptr_array_free(adv_service_uuids, TRUE);
        binc_adapter_start_advertising(default_adapter, advertisement);

        // Start application
        app = binc_create_application(default_adapter);
        binc_application_add_service(app, HTS_ADVERTISING_SERVICE_UUID);
        binc_application_add_service(app, HTS_SERVICE_UUID); // this is your real service, DON'T add it to the advertisement
        binc_application_add_characteristic(
                app,
                HTS_SERVICE_UUID,
                TEMPERATURE_CHAR_UUID,
                GATT_CHR_PROP_READ | GATT_CHR_PROP_INDICATE | GATT_CHR_PROP_WRITE);

or at least that's how I'm doing it, which results in one service being advertised until the device is paired, there may be more to it that Martijn might know.

from bluez_inc.

weliem avatar weliem commented on July 17, 2024

Unfortunately it is not (yet) possible to create characteristics that require encryption. I will put that on the backlog....

from bluez_inc.

tvquang-dev avatar tvquang-dev commented on July 17, 2024

Thanks @weliem , @lizziemac ,

I have tried as below and it's working

modified peripheral.c:

agent = binc_agent_create(default_adapter, "/org/bluez/BincAgent", DISPLAY_YES_NO);

modified application.c:
-------------- /binc/application.c --------------
index bf36272..90126e8 100644
@@ -697,7 +697,7 @@ static GList *permissions2Flags(const guint8 permissions)
GList *list = NULL;

 if (permissions & GATT_CHR_PROP_READ) {
  •    list = g_list_append(list, g_strdup("read"));
    
  •    list = g_list_append(list, g_strdup("encrypt-read"));
    
    }
    if (permissions & GATT_CHR_PROP_WRITE_WITHOUT_RESP) {
    list = g_list_append(list, g_strdup("write-without-response"));

modified characteristic.c:
------------- binc/characteristic.c -------------
index dcb1e83..577f846 100644
@@ -521,7 +521,7 @@ static guint binc_characteristic_flags_to_int(GList *flags) {
char *property = (char *) iterator->data;
if (g_str_equal(property, "broadcast")) {
result += GATT_CHR_PROP_BROADCAST;

  •        } else if (g_str_equal(property, "read")) {
    
  •        } else if (g_str_equal(property, "encrypt-read")) {
               result += GATT_CHR_PROP_READ;
           } else if (g_str_equal(property, "write-without-response")) {
               result += GATT_CHR_PROP_WRITE_WITHOUT_RESP;
    

from bluez_inc.

weliem avatar weliem commented on July 17, 2024

Closing issue

from bluez_inc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.