fireble 数据透传(MPU6050透传数据到手机APP)遇到问题请教

我是基于qpps做的一个小项目,用于学习,在过程中遇到很多小问题,最终都是安安帮忙解答,非常感谢。

目前做的这个小项目的进展是,在qpps中加入了MPU6050的驱动,且能成功采集到数据,现在遇到的问题就是:
我在usr_design.c采集到的数据,但是数据发到手机APP端是在app_qpps_task.c里面,我应该采用一种什么方法把数据送到app_qpps_task.c里呢?通过发送消息吗?我知道在app_qpps_task.c可以直接采集数据,但是这样感觉不太好。

不需要发送消息,app_qpps.c中app_qpps_data_send可以被usr_design.c调用,可以将需要发送的数据发送到手机端app中。

/*
 ****************************************************************************************
 * @brief Send a notification containing raw data - at connection.        *//**
 *
 * @param[in] conhdl Connection handle
 * @param[in] index Index of Characteristic to be sent
 * @param[in] length Length of data to be sent
 * @param[in] data Pointer to data to be sent
 *
 * @response QPPS_DATA_SEND_CFM
 * @description
 * This function is used by the application to send a raw data.
 *
 ****************************************************************************************
 */
void app_qpps_data_send(uint16_t conhdl, uint8_t index, uint8_t length, uint8_t *data)
{
    struct qpps_data_send_req * msg = KE_MSG_ALLOC_DYN(QPPS_DATA_SEND_REQ, TASK_QPPS, TASK_APP,
                                                       qpps_data_send_req, length);

    msg->conhdl = conhdl;
    msg->index = index;
    msg->length = length;
    memcpy(msg->data, data, length);

    ke_msg_send(msg);
}

安安 发表于 2015-7-17 14:27
不需要发送消息,app_qpps.c中app_qpps_data_send可以被usr_design.c调用,可以将需要发送的数据发送到手机 …

实际上是通过app_qpps_data_send来发送消息。对于用户来说,不需要去关心发送什么消息,怎么发送

app_qpps_data_send如果要被usr_design.c调用,是不是要在void app_qpps_data_send(uint16_t conhdl, uint8_t index, uint8_t length, uint8_t *data);前面加入extern关键字?

安安 发表于 2015-7-17 14:27
不需要发送消息,app_qpps.c中app_qpps_data_send可以被usr_design.c调用,可以将需要发送的数据发送到手机 …

app_qpps_data_send如果要被usr_design.c调用,是不是要在void app_qpps_data_send(uint16_t conhdl, uint8_t index, uint8_t length, uint8_t *data);前面加入extern关键字?

不需要,在这个函数实现的头文件内,已经做了extern的声明,.c文件只是实现函数,所以你看不到extern也能调用。但是声明该函数的头文件必须包含。