杰里耳机TWS之间的通讯
附上代码,根据需要修改
//==================接收==================//
#define TWS_FUNC_USER_TONE_SYNC TWS_FUNC_ID('U', 'T', 'O', 'N')
static void bt_tws_user_tone_sync(void *_data, u16 len, bool rx)
{
if (rx)
{
u8 *data = (u8 *)_data;
phone_or_charge = (*data);
// r_printf("vol_sync: %d, %d\n", data[0], data[1]);
}
}
REGISTER_TWS_FUNC_STUB(app_user_tone_sync) = {
.func_id = TWS_FUNC_USER_TONE_SYNC,
.func = bt_tws_user_tone_sync,
};
//==================接收==================//
//==================发出==================//
void bt_tws_sync_user_tone(void)
{
u8 data;
data = phone_or_charge;
//r_printf("[master]anc_sync: %d, %d\n", data[0], data[1]);
tws_api_send_data_to_slave(&data, 1, TWS_FUNC_USER_TONE_SYNC);
}
//==================发出==================//