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.

CC2541主动发数据给APP

Other Parts Discussed in Thread: CC2541

我的问题是如果APP没有开通notify功能,而app通过我这个函数simpleProfile_ReadAttrCB来读数据的时候,我这里数据还没有准备好。我要怎么把APP所需要的数据补上。

  • 不明白你的描述。


    如果APP端没有使能 peripheral notify则notify会失败。
  • 是的,如果APP端没有使能notify,我使用notify功能发数据是会失败的。APP一般都是通过这个函数simpleProfile_ReadAttrCB来问CC2541要数据。比如,这个函数晨有3个SIMPLEPROFILE_CHAR1_UUID,SIMPLEPROFILE_CHAR2_UUID,SIMPLEPROFILE_CHAR3_UUID. APP端来其中一个UUID这里来读数据,我有数据会用这个函数VOID osal_memcpy(pValue, temp_begin1, 11);将数据给APP端。有一种情况是APP端所需要的数据是MCU stm8 通过uart 发给CC2541 的。MCUstm8有可能延时了,没有把数据发给CC2541。但是APP端又在这时候来读数据,由于数据没有准备好,所以APP端没有读到数据。但是APP又只读一次,就不读了。然后MCU stm8延时一定时间后,将数据通过 UART发给了CC2541.现在CC2541要把数据发给APP端。但是APP端又不来读数据了。我怎么把数据给APP端
  • 你这种读数据无法保证及时更新,建议去用notify 去做。 read 只会读取当前值,你也可以自己在你的数据buff里面加序列号,然后做判断,APP读的数据是否处理。
  • 我可不可以在这个函数simpleProfile_ReadAttrCB里做延时啊,延时一段时间之后等待MCU stm8把数据准备好了再发给APP端
  • 不能,如果不回复,会timeout

    A transaction not completed within 30 seconds shall time out. Such a transaction shall be considered to have failed and the local higher layers shall be informed of this failure. No more attribute protocol requests, commands, indications or notifications shall be sent to the target device on this ATT Bearer.