Changed unordered_set to vector when checking for duplicate AID

This eliminated the use of unordered_set everywhere in HomeSpan
This commit is contained in:
Gregg 2023-11-12 12:33:09 -06:00
parent 98d6abeb1f
commit 1e62a038f1
3 changed files with 3 additions and 8 deletions

View File

@ -865,7 +865,7 @@ void Span::processSerialCommand(const char *c){
int nErrors=0;
int nWarnings=0;
unordered_set<uint32_t> aidValues;
vector<uint32_t> aidValues;
char pNames[][7]={"PR","PW","EV","AA","TW","HD","WR"};
for(auto acc=Accessories.begin(); acc!=Accessories.end(); acc++){
@ -875,10 +875,10 @@ void Span::processSerialCommand(const char *c){
if(acc==Accessories.begin() && (*acc)->aid!=1)
LOG0(" *** ERROR #%d! AID of first Accessory must always be 1 ***\n",++nErrors);
if(aidValues.find((*acc)->aid)!=aidValues.end())
if(std::find(aidValues.begin(),aidValues.end(),(*acc)->aid)!=aidValues.end())
LOG0(" *** ERROR #%d! AID already in use for another Accessory ***\n",++nErrors);
aidValues.insert((*acc)->aid);
aidValues.push_back((*acc)->aid);
for(auto svc=(*acc)->Services.begin(); svc!=(*acc)->Services.end(); svc++){
LOG0(" \u279f Service %s: IID=%d, %sUUID=\"%s\"\n",(*svc)->hapName,(*svc)->iid,(*svc)->isCustom?"Custom-":"",(*svc)->type);

View File

@ -37,7 +37,6 @@
#include <Arduino.h>
#include <unordered_map>
#include <vector>
#include <unordered_set>
#include <list>
#include <nvs.h>
#include <ArduinoOTA.h>
@ -55,7 +54,6 @@
using std::vector;
using std::unordered_map;
using std::unordered_set;
using std::list;
enum {

View File

@ -28,11 +28,8 @@
#pragma once
#include <WiFi.h>
#include <unordered_set>
#include "Settings.h"
using std::unordered_set;
const int MAX_SSID=32; // max number of characters in WiFi SSID
const int MAX_PWD=64; // max number of characters in WiFi Password