This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Enabling notification from Btool

Other Parts Discussed in Thread: CC2540

Hello all,

I am very new to embedded systems and programming and just started working with CC2540 mini kit. I am trying to understand how it works by going through OSAL, HAL document and anything coming on my way. During this time I started playing with simpleBLEperipheral application and found out that notification from keyfob can be enabled for characteristic 4 and key press. I read about what needs to be done and tried it as given in some ti document. I first read handle using discover characteristic by UUID and wrote 01:00.

First time i wrote successfully and i was getting notifications from keyfob but when i disabled and tried to enable( i mean writing 00:00 and again 01:00), i couldn't do it. It gave me Write_not_permitted error.  I tried this after two days, it worked then when i tried again to enable after disabling. I am getting same error msg. I think there is another characteristic which can send notification at UUID FFE1. I haven't been able to enable it even once.

I am really confused and thinking what could be the reason for such behavior. If anybody has encountered such problem and solved it. Please help me out.

I also read in forums that notification can be enabled using GATT_Notification and some other GATT API in application itself. But I don't know arguments that need to be passed.

Waiting for response and Thank you in advance.

  • To enable notifications for a characteristic you must write to the characteristic configuration, which is the handle immediately after the characteristic itself. So, use "Discover Characteristic by UUID" to get the handle for UUID 0xFFE1, add 1 to that handle and use "Characteristic Write" to write 01:00 there. That should enable notifications if the characteristic supports them.
  • Thank you Matthew for your response.

    I am doing as you suggested. But I am getting "write not permitted" error for FFE1 (handle 0x0036) all the time. Whereas I have been able to enable notification for characteristics 4 ( handle 0x002E) twice and other time i am getting same error msg.

    What could be the problem? If anyone can suggest anything would be greatly appreciated.

    Thank you again.

  • In the simpleGATTprofile example code there are five example characteristics but only one of them (number 4) supports notifications. See Projects/ble/Profiles/SimpleProfile/simpleGATTprofile.c line 160 et al.

    If you want to add support for notifications to one of the other characteristics (or one of you own) you need to copy the relevant code from the number 4 characteristic. There are changes to the attribute table (including the extra entry for the characteristic configuration) and there is also extra code in SimpleProfile_SetParameter() (line 467) to handle sending the notification when the value changes.

  • Thank you again Matthew.

    As of now I just want to be able to enable notification for characteristic 4 everytime i wish. As I said earlier, I could enable only twice in 3-4 days.

    I am confused why it got enabled then and again not enabled. Could there be other problems? I am powering keyfob with debugger this entire time (when i could enable notification also).

    I updated firmware of my CC debugger also to latest version thinking it might have caused problem, but problem persists.

  • It worksforme. I discover the handle for UUID FFE1, add 1, write 01:00 there and notifications are enabled (I see them when I press a key). I can write 00:00 to turn them off and write 01:00 to turn them on again as many times as I like. Traps for the unwary: Make sure that the Characteristic Write dialog is in Hex and that you have the number entered LSB first (i.e. 01:00 not 00:01). If it is the wrong way round you get INVALID_VALUE status. Check that the Characteristic Write dialog has the correct Connection Handle - it's usually 0x0000 but may be different if you have connected to more than one target, or disconnected and reconnected quickly. If this is wrong you get status of Invalid Parameter. Look in the left-hand tree view to see the active connections. Are you powering it properly from the CC Debugger? The debugger supplies power from pin 9 (and uses pin 2 to sense). The sample keyfob devices do not make use of pin 9. If you haven't made connection here the device may just be powered parasitically from the data lines.
  • Thank you Mathhew for all response.

    I tested this powering with battery and not debugger also. But i can't enable notification. I am having this feeling that the problem is with keyfob IC.

    By the way, this thing i was trying is to enable notification by client to server. Is it possible to enable notification by server itself with some command like GATT_Notification or something? If yes, Please can anyone provide me the code with arguments. I am having difficulty understanding what argument needs to be used.

  • Hi maharjan,

    I'm not sure if you knew this, but to enable a notification for a characteristic, you actually need to write to the handle of that characteristic + 1. This is just the way the GATT attribute table is designed, where Client Characteristic Configuration is a descriptor laid out after the characteristic itself. If you try to write to the char that is defined as notification, you will get WRITE_NOT_PERMITTED.

    Have a look at this walkthrough, maybe it's informative.

    http://processors.wiki.ti.com/index.php/LPRF_BLE_Simple_Application

    Best regards,
    Aslak

  • Thank you Aslak,

    I didn't know it. I started studying and playing with mini kit some 2 weeks ago.

    Now it is working.

    Regards,

    Bishnu