Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <string>
- #include <curl/curl.h>
- using namespace std;
- static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
- {
- ((std::string*)userp)->append((char*)contents, size * nmemb);
- return size * nmemb;
- }
- int main(){
- CURL *curl;
- CURLcode res;
- std::string readBuffer;
- std::string password = "123456789";
- curl = curl_easy_init();
- if(curl) {
- curl_easy_setopt(curl, CURLOPT_URL, "");
- curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
- curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
- curl_easy_setopt(curl, CURLOPT_POST, 1);
- curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "pass="+password);
- res = curl_easy_perform(curl);
- curl_easy_cleanup(curl);
- // std::cout << readBuffer << std::en;dl;
- system("stty -F /dev/serial0 19200");
- echo(readBuffer);
- }
- else{
- return 200;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement