MCPcopy Create free account
hub / github.com/BlueAndi/Pixelix / startHttpRequest

Method startHttpRequest

lib/SignalDetectorPlugin/src/SignalDetectorPlugin.cpp:448–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

446}
447
448bool SignalDetectorPlugin::startHttpRequest()
449{
450 bool status = false;
451 RestService::PreProcessCallback preProcessCallback = [](const char* payload, size_t size, DynamicJsonDocument& doc) {
452 UTIL_NOT_USED(payload);
453 UTIL_NOT_USED(size);
454 UTIL_NOT_USED(doc);
455
456 LOG_INFO("Signal detection reported.");
457
458 return true;
459 };
460
461 if (false == m_pushUrl.isEmpty())
462 {
463 String url = m_pushUrl;
464 const char* GET_CMD = "get ";
465 const char* POST_CMD = "post ";
466 bool isGet = true;
467
468 /* URL prefix might indicate the kind of request. */
469 url.toLowerCase();
470 if (true == url.startsWith(GET_CMD))
471 {
472 url = url.substring(strlen(GET_CMD));
473 isGet = true;
474 }
475 else if (true == url.startsWith(POST_CMD))
476 {
477 url = url.substring(strlen(POST_CMD));
478 isGet = false;
479 }
480 else
481 {
482 ;
483 }
484
485 if (false == isGet)
486 {
487 m_dynamicRestId = RestService::getInstance().post(url, preProcessCallback);
488
489 if (RestService::INVALID_REST_ID == m_dynamicRestId)
490 {
491 LOG_WARNING("POST %s failed.", url.c_str());
492 }
493 else
494 {
495 status = true;
496 }
497 }
498 else
499 {
500 m_dynamicRestId = RestService::getInstance().get(url, preProcessCallback);
501
502 if (RestService::INVALID_REST_ID == m_dynamicRestId)
503 {
504 LOG_WARNING("GET %s failed.", url.c_str());
505 }

Callers

nothing calls this directly

Calls 6

startsWithMethod · 0.80
substringMethod · 0.80
c_strMethod · 0.80
isEmptyMethod · 0.45
postMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected