Learn how to build a project using the C++ REST SDK NuGet package
git checkout v2.2.0
Enable Enhanced Instruction Set
= No Enhanced Instructions (/arch:IA32)
for both Debug and Release\\mygalileo\c$\test
in file explorer (create the “test” folder if necessary).cpprest120d_2_2.dll
file (generated during the build step and placed at git_root_folder\casablanca\Binaries\Win32\Debug), into the “test” folder from the previous step.Install-Package cpprestsdk -Version 2.2.0
into the command line.// Main.cpp : Defines the entry point for the console application.
//
#include <cpprest/http_client.h>
#include <cpprest/filestream.h>
#include "stdafx.h"
#include "arduino.h"
int _tmain(int argc, _TCHAR* argv[])
{
return RunArduinoSketch();
}
void setup()
{
std::shared_ptr<concurrency::streams::ostream> fileStream = std::make_shared<concurrency::streams::ostream>();
// Open stream to output file.
concurrency::task<void> requestTask = concurrency::streams::fstream::open_ostream(U("results.html")).then([=](concurrency::streams::ostream outFile)
{
*fileStream = outFile;
// Create http_client to send the request.
web::http::client::http_client client(U("http://www.bing.com/"));
// Build request URI and start the request.
web::http::uri_builder builder(U("/search"));
builder.append_query(U("q"), U("Casablanca CodePlex"));
return client.request(web::http::methods::GET, builder.to_string());
})
// Handle response headers arriving.
.then([=](web::http::http_response response)
{
printf("Received response status code:%u\n", response.status_code());
// Write response body into the file.
return response.body().read_to_end(fileStream->streambuf());
})
// Close the file stream.
.then([=](size_t)
{
return fileStream->close();
});
// Wait for all the outstanding I/O to complete and handle any exceptions
try
{
requestTask.wait();
}
catch (const std::exception &e)
{
printf("Error exception:%s\n", e.what());
}
}
// the loop routine runs over and over again forever:
void loop()
{
_exit_arduino_loop();
}