"as_cb( )" as callback?

Hi, I am trying to develop a BLE project with two boards communicating. I am looking at the examples available and I have seen several times “as_cb( )” like in the following example:

ble_error_t error = characteristic.read( 0, as_cb(&Self::when_characteristic_read) );

The problem is that I get a compilation error “as_cb” was not defined in this scope.
I have searched many headers and I don’t find the definition of “as_cb”.

Does anybody know where it is ?


José Ignacio


usually is good to share a link to the example what you are talking about.

It is not in any header it seems to be a template function

BR, Jan

Here you have a link to the example that uses several times “as_cb”


The example is probably older version of example what I posted above.

The main() function is on line 559. The code above is a class GattClientProcess and as_cb(...) is its private method

    template<typename ContextType> 
    FunctionPointerWithContext<ContextType> as_cb(void (Self::*member)(ContextType context) )
        return makeFunctionPointer(this, member);

I tried to compile this code for Nucleo-F401 and after correcting line 446 (change from false to NULL) the compilation was OK with few warnings.

BR, Jan

Thank you very much for your help, I was using the example as a guide but missed that part of the code where it was defined, I was getting mad trying to find it in the header files.
Best Regards
José Ignacio

I thought something like that.
You are welcome and good luck.

BR, Jan