bool MediaServer::call_http(const http::http_request& /*req*/, const boost::filesystem::path& root, const boost::filesystem::path& rest, http::response& resp) { auto media_type = items::main_resource; if (root == "thumb") media_type = items::thumbnail; else if (root == "thumb-160") media_type = items::thumbnail_160; else if (root != "media") return false; auto item = get_item(rest.string()); if (!item) return false; auto info = item->get_media(media_type); if (!info) return false; resp.header().clear(server()); return info->prep_response(resp); }
int main(void) { usi_enable(); spiX_initslave(SPIMODE); sei(); //Initialize slave slave_init(); //Let settings catch up _delay_ms(100); //An initial packet, not sure what it's for, but the other code had it prepare_packet("", 0); spiX_put(0); unsigned char input; do{ //Wait for SS while(!slave_selected()); //Wait for pending transfers spiX_wait(); //Read first character from master input = spiX_get(); //Is the master telling us to receive? //If so, interpret the input and prepare a response packet if(input == RECEIVE_CHAR) { //Retrieve the rest of the packet from master receive_packet(); //Check integrity if(!check_integrity()) { prep_err(); continue; } //Lowercase are read operations if(incoming_packet[1] > 96 && incoming_packet[1] < 127) { prep_response(incoming_packet[1]); } else { do_action(incoming_packet[1]); } } //Is the master telling us that it's ready to receive? else if(input == SEND_CHAR) { //Send the prepared packet send_packet(); } if(waiting_measure){ slave_run_measure(); waiting_measure = 0; } if(waiting_write){ slave_apply(); waiting_write = 0; } } while(1); // Loop forever... }