app_lsm6dso_context_t* g_six_d = NULL;
void bt_sink_srv_event_lsm6dso_six_d(int cur_state)
{
int old_state = g_six_d->lsm6dso_state;
g_six_d->lsm6dso_state = cur_state;
bool ret = true;
switch(cur_state)
{
case STATE_LSM6DSO_XH:
{
printf("###### function = %s, line = %d.STATE_LSM6DSO_XH", __FUNCTION__, __LINE__);
bt_sink_srv_event_callback_timeout_remove(BT_SINK_SRV_EVENT_SIX_D);
bt_sink_srv_event_callback_timeout(BT_SINK_SRV_EVENT_SIX_D, NULL, 0, 250);
break;
}
case STATE_LSM6DSO_XL:
{
printf("###### function = %s, line = %d.STATE_LSM6DSO_XL", __FUNCTION__, __LINE__);
bt_sink_srv_event_callback_timeout_remove(BT_SINK_SRV_EVENT_SIX_D);
bt_sink_srv_event_callback_timeout(BT_SINK_SRV_EVENT_SIX_D, NULL, 0, 250);
break;
}
case STATE_LSM6DSO_YH:
{
printf("###### function = %s, line = %d.STATE_LSM6DSO_YH", __FUNCTION__, __LINE__);
if(old_state == STATE_LSM6DSO_XH && cur_state == STATE_LSM6DSO_YH)
{
printf("###### function = %s, line = %d.STATE_LSM6DSO_XH-STATE_LSM6DSO_YH", __FUNCTION__, __LINE__);
bt_sink_srv_event_callback_timeout_remove(BT_SINK_SRV_EVENT_SIX_D);
bt_sink_srv_event_callback_timeout(BT_SINK_SRV_EVENT_SIX_D, NULL, 0, 250);
}
break;
}
default:
{
ret = false;
break;
}
}
}
typedef struct {
int lsm6dso_state;
} app_lsm6dso_context_t;
我想在一个switch语句里面当前case下,获取上一个case状态是什么,可以怎么写,我使用一个 结构体变量在外面保存这样会死机,请问语法有什么问题吗