Git Product home page Git Product logo

Comments (4)

remay avatar remay commented on July 17, 2024

Just for the record I have been using this extension to DiscoveredCharacteristics, which is very similar to your proposed DiscoveredCharacteristic::enableNotification():

ble_error_t
DiscoveredCharacteristic::requestHVX(HVXType_t type) const
{
    if (!props.write()) {
        return BLE_ERROR_OPERATION_NOT_PERMITTED;
    }

    if (!props.notify()) {
        return BLE_ERROR_OPERATION_NOT_PERMITTED;
    }

    if (!gattc) {
        return BLE_ERROR_INVALID_STATE;
    }

    /* Cargo Culted from: https://developer.mbed.org/teams/Bluetooth-Low-Energy/code/BLE_ButtonSense/file/2dec89c76f68/main.cpp */
    /* HACK. We're assuming that CCCD descriptor immediately follows the value attribute. */
    /* TODO actually discover the handle for the CCCD descriptor */
    uint16_t value = (uint16_t)type;
    return gattc->write(GattClient::GATT_OP_WRITE_REQ, connHandle, valueHandle + 1, sizeof(value), (const uint8_t*)(&value));
}

I know it doesn't solve the real problem of descriptor discovery, but it does hide away the hack to somewhere that they can be worked on without effecting user code.

from ble.

remay avatar remay commented on July 17, 2024

And, of course, having posted that I see that the second test in not correct for indications, that have their own property. But you get the idea.

from ble.

remay avatar remay commented on July 17, 2024

Update, this is what I'm currently using:

DiscoveredCharacteristic::requestHVX(HVXType_t type) const
{
    if (type == BLE_HVX_NOTIFICATION && !props.notify()) {
        return BLE_ERROR_OPERATION_NOT_PERMITTED;
    }

    if (type == BLE_HVX_INDICATION && !props.indicate()) {
        return BLE_ERROR_OPERATION_NOT_PERMITTED;
    }

    if (!gattc) {
        return BLE_ERROR_INVALID_STATE;
    }

    /* Cargo Culted from: https://developer.mbed.org/teams/Bluetooth-Low-Energy/code/BLE_ButtonSense/file/2dec89c76f68/main.cpp */
    /* HACK. We're assuming that CCCD descriptor immediately follows the value attribute. */
    /* TODO actually discover the handle for the CCCD descriptor */
    uint16_t value = (uint16_t)type;
    return gattc->write(GattClient::GATT_OP_WRITE_REQ, connHandle, valueHandle + 1, sizeof(value), (const uint8_t*)(&value));
}

from ble.

rainierwolfcastle avatar rainierwolfcastle commented on July 17, 2024

ARM Internal Ref: IOTSFW-1033

from ble.

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.