本文整理汇总了C++中PSOCK_BEGIN函数的典型用法代码示例。如果您正苦于以下问题:C++ PSOCK_BEGIN函数的具体用法?C++ PSOCK_BEGIN怎么用?C++ PSOCK_BEGIN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PSOCK_BEGIN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PT_THREAD
/*---------------------------------------------------------------------------*/
static
PT_THREAD(processes(struct httpd_state *s, char *ptr))
{
PSOCK_BEGIN(&s->sout);
for(s->u.ptr = PROCESS_LIST(); s->u.ptr != NULL; s->u.ptr = ((struct process *)s->u.ptr)->next) {
PSOCK_GENERATOR_SEND(&s->sout, make_processes, s->u.ptr);
}
PSOCK_END(&s->sout);
}
示例2: PT_THREAD
/*---------------------------------------------------------------------------*/
static
PT_THREAD(file_stats(struct httpd_state *s, char *ptr))
{
PSOCK_BEGIN(&s->sout);
PSOCK_GENERATOR_SEND(&s->sout, generate_file_stats, strchr(ptr, ' ') + 1);
PSOCK_END(&s->sout);
}
示例3: PT_THREAD
static
PT_THREAD(send_part_of_file(struct httpd_state *s))
{
PSOCK_BEGIN(&s->sout);
PSOCK_GENERATOR_SEND(&s->sout, generate_len_part_of_file, s);
PSOCK_END(&s->sout);
}
示例4: PT_THREAD
/*---------------------------------------------------------------------------*/
static
PT_THREAD(send_part_of_file(struct httpd_state *s))
{
PSOCK_BEGIN(&s->sout);
PSOCK_SEND(&s->sout, s->file.data, s->len);
PSOCK_END(&s->sout);
}
示例5: PT_THREAD
static
PT_THREAD(sensorscall(struct httpd_state *s, char *ptr))
{
static struct timer t;
static int i;
static char buf[100];
static unsigned long last_cpu, last_lpm, last_listen, last_transmit;
PSOCK_BEGIN(&s->sout);
timer_set(&t, CLOCK_SECOND);
i = 0;
/* while(1)*/ {
/* timer_restart(&t);
PSOCK_WAIT_UNTIL(&s->sout, timer_expired(&t));*/
#if CONTIKI_TARGET_SKY
SENSORS_ACTIVATE(sht11_sensor);
SENSORS_ACTIVATE(light_sensor);
snprintf(buf, sizeof(buf),
"t(%d);h(%d);l1(%d);l2(%d);",
sht11_sensor.value(SHT11_SENSOR_TEMP),
sht11_sensor.value(SHT11_SENSOR_HUMIDITY),
light_sensor.value(LIGHT_SENSOR_PHOTOSYNTHETIC),
light_sensor.value(LIGHT_SENSOR_TOTAL_SOLAR));
SENSORS_DEACTIVATE(sht11_sensor);
SENSORS_DEACTIVATE(light_sensor);
#else /* CONTIKI_TARGET_SKY */
snprintf(buf, sizeof(buf),
"t(%d);h(%d);l1(%d);l2(%d);",
0,
0,
0,
0);
#endif /* CONTIKI_TARGET_SKY */
PSOCK_SEND_STR(&s->sout, buf);
/* timer_restart(&t);
PSOCK_WAIT_UNTIL(&s->sout, timer_expired(&t));*/
snprintf(buf, sizeof(buf),
"p(%lu,%lu,%lu,%lu);i(%d);",
energest_type_time(ENERGEST_TYPE_CPU) - last_cpu,
energest_type_time(ENERGEST_TYPE_LPM) - last_lpm,
energest_type_time(ENERGEST_TYPE_TRANSMIT) - last_transmit,
energest_type_time(ENERGEST_TYPE_LISTEN) - last_listen,
i++);
last_cpu = energest_type_time(ENERGEST_TYPE_CPU);
last_lpm = energest_type_time(ENERGEST_TYPE_LPM);
last_transmit = energest_type_time(ENERGEST_TYPE_TRANSMIT);
last_listen = energest_type_time(ENERGEST_TYPE_LISTEN);
PSOCK_SEND_STR(&s->sout, buf);
}
PSOCK_END(&s->sout);
}
示例6: PT_THREAD
/*---------------------------------------------------------------------------*/
static
PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr))
{
PSOCK_BEGIN(&s->sout);
SEND_STRING(&s->sout, statushdr);
SEND_STRING(&s->sout, get_content_type(s->filename));
PSOCK_END(&s->sout);
}
示例7: PT_THREAD
/*---------------------------------------------------------------------------*/
static
PT_THREAD(header(struct httpd_state *s, char *ptr))
{
PSOCK_BEGIN(&s->sout);
PSOCK_GENERATOR_SEND(&s->sout, generate_header, (void *) ptr);
PSOCK_END(&s->sout);
}
示例8: PT_THREAD
static PT_THREAD(handle_output(contiki_data_t *s))
{
PSOCK_BEGIN(&s->p);
if (s->state == WRITTING) {
PSOCK_SEND(&s->p, s->out_buf, s->out_len);
s->state = WRITE_END;
process_post_synch(s->process, xively_event, s);
}
PSOCK_END(&s->p);
}
示例9: PT_THREAD
/*
=======================================================================================================================
=======================================================================================================================
*/
static PT_THREAD(handle_input (struct httpd_state *s))
{
PSOCK_BEGIN(&s->sin);
PSOCK_READTO(&s->sin, ISO_space);
if(strncmp(s->inputbuf, http_get, 4) != 0)
{
PSOCK_CLOSE_EXIT(&s->sin);
}
PSOCK_READTO(&s->sin, ISO_space);
if(s->inputbuf[0] != ISO_slash)
{
PSOCK_CLOSE_EXIT(&s->sin);
}
if(s->inputbuf[1] == ISO_space)
{
strncpy(s->filename, http_index_html, sizeof(s->filename));
}
else
{
s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0;
/* Process any form input being sent to the server. */
{
/*
* extern void vApplicationProcessFormInput( char *pcInputString, long
* xInputLength ); £
* vApplicationProcessFormInput( s->inputbuf, PSOCK_DATALEN(&s->sin) );
*/
}
strncpy(s->filename, &s->inputbuf[0], sizeof(s->filename));
}
/* httpd_log_file(uip_conn->ripaddr, s->filename); */
s->state = STATE_OUTPUT;
while(1)
{
PSOCK_READTO(&s->sin, ISO_nl);
if(strncmp(s->inputbuf, http_referer, 8) == 0)
{
s->inputbuf[PSOCK_DATALEN(&s->sin) - 2] = 0;
/* httpd_log(&s->inputbuf[9]); */
}
}
PSOCK_END(&s->sin);
}
示例10: PT_THREAD
static PT_THREAD(send_file(struct httpd_state *s)) {
PSOCK_BEGIN(&s->sout);
do {
PSOCK_GENERATOR_SEND(&s->sout, generate_part_of_file, s);
s->file.len -= s->len;
s->file.data += s->len;
} while(s->file.len > 0);
PSOCK_END(&s->sout);
}
示例11: PT_THREAD
/*---------------------------------------------------------------------------*/
static
PT_THREAD(file_stats(struct httpd_state *s, char *ptr))
{
PSOCK_BEGIN(&s->sout);
//while (pgm_read_byte(ptr++)!=' ') {}; //skip to "/filename" after the script invokation
PSOCK_GENERATOR_SEND(&s->sout, generate_file_stats, (void *) (strchr_P(ptr, ' ') + 1));
PSOCK_END(&s->sout);
}
示例12: PT_THREAD
/*---------------------------------------------------------------------------*/
static PT_THREAD( handle_input ( struct httpd_state *s ) )
{
PSOCK_BEGIN( &s->sin );
( void ) PT_YIELD_FLAG;
PSOCK_READTO( &s->sin, ISO_space );
if( strncmp(s->inputbuf, http_get, 4) != 0 )
{
PSOCK_CLOSE_EXIT( &s->sin );
}
PSOCK_READTO( &s->sin, ISO_space );
if( s->inputbuf[0] != ISO_slash )
{
PSOCK_CLOSE_EXIT( &s->sin );
}
if( s->inputbuf[1] == ISO_space )
{
strncpy( s->filename, http_index_html, sizeof(s->filename) );
}
else
{
s->inputbuf[PSOCK_DATALEN( &s->sin ) - 1] = 0;
/* Process any form input being sent to the server. */
#if UIP_CONF_PROCESS_HTTPD_FORMS == 1
{
extern void vApplicationProcessFormInput( char *pcInputString );
vApplicationProcessFormInput( s->inputbuf );
}
#endif
strncpy( s->filename, &s->inputbuf[0], sizeof(s->filename) );
}
/* httpd_log_file(uip_conn->ripaddr, s->filename);*/
s->state = STATE_OUTPUT;
while( 1 )
{
PSOCK_READTO( &s->sin, ISO_nl );
if( strncmp(s->inputbuf, http_referer, 8) == 0 )
{
s->inputbuf[PSOCK_DATALEN( &s->sin ) - 2] = 0;
/* httpd_log(&s->inputbuf[9]);*/
}
}
PSOCK_END( &s->sin );
}
示例13: PT_THREAD
static PT_THREAD(lights_list(struct httpd_state *s, char *))
{
PSOCK_BEGIN(&s->sout);
for(s->count = 0; lights[s->count].is_valid_P(); ++s->count) {
PSOCK_GENERATOR_SEND(&s->sout, generate_lights_list, s);
}
PSOCK_END(&s->sout);
}
示例14: PT_THREAD
//const char http_content_type_json[] = "Content-type:application/json\n\n";
static
PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr))
{
PSOCK_BEGIN(&s->sout);
SEND_STRING(&s->sout, statushdr);
//SEND_STRING(&s->sout, http_content_type_json);
PSOCK_END(&s->sout);
}
示例15: PT_THREAD
/*---------------------------------------------------------------------------*/
static
PT_THREAD(rplreset(struct httpd_state *s, char *ptr))
{
PSOCK_BEGIN(&s->sout);
if(rpl_repair_root(RPL_DEFAULT_INSTANCE)) {
PSOCK_SEND_STR(&s->sout, "Initiating global repair of RPL network...");
} else {
PSOCK_SEND_STR(&s->sout, "Could not start global network repair");
}
PSOCK_END(&s->sout);
}