void processCurrentBridgeCandidate() { if (currentBridgeCandidate!=bridgeCandiates.end()) { // request description XML hueComm.bridgeAPIComm.httpRequest( (currentBridgeCandidate->second).c_str(), boost::bind(&BridgeFinder::handleServiceDescriptionAnswer, this, _1, _2), "GET" ); } else { // done with all candidates if (refind) { // failed getting description, return error callback(ErrorPtr(new HueCommError(HueCommErrorDescription))); keepAlive.reset(); // will delete object if nobody else keeps it return; // done } else { // finding new bridges - attempt user login bridgeCandiates.clear(); // now attempt to pair with one of the candidates startedAuth = MainLoop::now(); attemptPairingWithCandidates(); } } }
void bridgeRefindHandler(SsdpSearchPtr aSsdpSearch, ErrorPtr aError) { if (!Error::isOK(aError)) { // could not find bridge, return error callback(ErrorPtr(new HueCommError(HueCommErrorUuidNotFound))); keepAlive.reset(); // will delete object if nobody else keeps it return; // done } else { // found, now get description to get baseURL // - put it into queue as the only candidate bridgeCandiates.clear(); bridgeCandiates[aSsdpSearch->uuid.c_str()] = aSsdpSearch->locationURL.c_str(); // process the candidate currentBridgeCandidate = bridgeCandiates.begin(); processCurrentBridgeCandidate(); } }
void findNewBridge(const char *aUserName, const char *aDeviceType, MLMicroSeconds aAuthTimeWindow, HueComm::HueBridgeFindCB aFindHandler) { refind = false; callback = aFindHandler; userName = nonNullCStr(aUserName); deviceType = nonNullCStr(aDeviceType); authTimeWindow = aAuthTimeWindow; if (hueComm.fixedBaseURL.empty()) { // actually search for a bridge keepAlive = BridgeFinderPtr(this); bridgeDetector->startSearch(boost::bind(&BridgeFinder::bridgeDiscoveryHandler, this, _1, _2), NULL); } else { // we have a pre-known base URL for the hue API, use this without any find operation keepAlive = BridgeFinderPtr(this); // - just put it in as the only auth candidate authCandidates.clear(); authCandidates[PSEUDO_UUID_FOR_FIXED_API] = hueComm.fixedBaseURL; startedAuth = MainLoop::now(); attemptPairingWithCandidates(); } };
void Update(const ns6__ECLResult * c) { clib::recursive_mutex::scoped_lock proc(m_mutex); SAFE_ASSIGN2CSTRING(m_name, c->Name); SAFE_ASSIGN(m_sequence, c->Sequence); SAFE_ASSIGN2CSTRING(m_value, c->Value); SAFE_ASSIGN2CSTRING(m_link, c->Link); SAFE_ASSIGN(IsSupplied, c->IsSupplied); SAFE_ASSIGN(m_total, c->Total); SAFE_ASSIGN2CSTRING(m_fileName, c->FileName); if (c->ECLSchemas) { m_schemaMap.clear(); for(std::size_t i = 0; i < c->ECLSchemas->ECLSchemaItem.size(); ++i) { if (c->ECLSchemas->ECLSchemaItem[i]->ColumnName && c->ECLSchemas->ECLSchemaItem[i]->ColumnType) { m_schemaMap[*c->ECLSchemas->ECLSchemaItem[i]->ColumnName] = *c->ECLSchemas->ECLSchemaItem[i]->ColumnType; } } } }
void Clear() { nvs.clear(); }