/*---------------------------------------------------------------------------*/ static PT_THREAD(set_pin(struct httpd_state *s, char *)) { char* pin_at; char* val_at; const char* response = str_notfound; PSOCK_BEGIN(&s->sout); // Take action nanode_log(s->filename); pin_at = strstr(s->filename,"pin="); val_at = strstr(s->filename,"val="); if ( pin_at && val_at ) { uint8_t pin = atoi(pin_at+4); uint8_t val = atoi(val_at+4); digitalWrite(pin,val); response = digitalRead(pin)?str_high:str_low; } // Send response PSOCK_SEND_P(&s->sout,(uint8_t*)response,strlen_P(response)); PSOCK_END(&s->sout); }
void result(struct httpd_fs_file *file) const { file->data = data; file->len = pgm_read_word(len); nanode_log_P(PSTR("http: entry result")); nanode_log((char *)data); }
// Note that 'filename' might not be zero-terminated! int httpd_fs_open(const char *filename, struct httpd_fs_file *file) { nanode_log_P(PSTR("http: file open")); nanode_log((char*)filename); int result = 0; const file_entry_t* cur = dir; bool done = false; while (!done) { entry e(cur); if (e.matches(filename)) { e.result(file); done = 1; result = 1; } if (!e.isvalid()) done = 1; ++cur; } return result; }