Out of memory when creating a characteristic

I am creating the Battery characteristic in a Battery service but I run out of memory (0x04 error) when generating the characteristic.  However, that makes no sense. I have the same set of characteristics for several different health devices, blood pressure, glucose, spirometer, thermometer, heart rate, and scale. Only the glucose and the spirometer run out of memory generating a characteristic. In the spirometer case, the reg cert data list char fails in the DIS but the Battery Service and battery do not and they are generated after the DIS.

WHen I build in Keil, I get the size of code and it is only 41K bytes. This is small compared to most of the BT SIG profile examples. The program runs fine but those characteristics that don't get created are not part of the service table.

I am not sure how to solve this issue or why it even happens.

  • However, my question is how can I determine the size of the service table?

    That would be a very useful feature, but I don't think you can. Here is an old depressing answer that says trial and error is the only way. I don't think the situation has changed in five years.

    I think one of the major influences maybe the size of the DIS as there are many fixed strings like the manufacturer name which depend upon the user.

    I was going to say that there is a fixed maximum size for those that is accounted for, but then I checked. The DIS implementation by Nordic uses the length of the input given at initialization also as a maximum size. So if these are input by the user and not length limited by the application, then I believe they could exceed the size allocated for the attribute table.

    What if you now input a manufacturer name string that is 64 bytes longer than before? Do you hit the same out of memory error? I think you probably will.

    I actually have the same situation with my product. Except that the DIS strings are input by a production test device so they shouldn't get arbitrarily larger.

  • I have not tried making the DIS strings larger. But that was just an example of the type of thing that might be causing problems. However, there must be more than just the characteristic value that determines the size of the service table. 

    In any case, it probably is going to be trial and error. But it would be nice to have some idea so one would know how to set the values. Maybe set some max sizes as well.

Related