使用Contiki上的Erbium REST保持CoAP响应,直到收到UDP响应

使用Contiki上的Erbium REST保持CoAP响应,直到收到UDP响应,udp,contiki,coap,Udp,Contiki,Coap,我想对一个铒REST微尘做一个CoAP请求,在这个请求中,我首先请求另一个微尘的信息,以便在响应中使用 为此,我命令REST mote向另一个mote发送UDP消息。此微尘将返回带有信息的响应。但是,此信息是异步接收的,在收到此信息之前,我无法阻止CoAP处理程序 static void res_info_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset

我想对一个铒REST微尘做一个CoAP请求,在这个请求中,我首先请求另一个微尘的信息,以便在响应中使用

为此,我命令REST mote向另一个mote发送UDP消息。此微尘将返回带有信息的响应。但是,此信息是异步接收的,在收到此信息之前,我无法阻止CoAP处理程序

static void res_info_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
RESOURCE(res_info,
         "title=\"Getting info: ?len=0..\";rt=\"Text\"",
         res_info_handler,
         NULL,
         NULL,
         NULL);

static void
res_info_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
  send_to_mote("getInfo");

  //wait for the response: yield to other processes

  //if response has been received: continue
  response = info;

  REST.set_header_etag(response, (uint8_t *)&length, 1);
  REST.set_response_payload(response, buffer, length);
}
来自udp请求的数据在tcpip_处理程序中接收(从udp进程重复执行)


有人知道我如何才能做到这一点吗?

由于铒是基于康蒂基的,康蒂基的任务机制适用;对它们进行了描述

要点是,如果您想让位于其他进程,您可以直接
PROCESS\u yield()
;这将暂停对该线程的处理,直到通过向其发布事件将其从接收处理程序中唤醒

static void
tcpip_handler(void)
{
  char *str;

  if(uip_newdata()) {
    str = uip_appdata;
    str[uip_datalen()] = '\0';
    printf("ER: DATA recv '%s'\n", str);
    info = str;
  }
}