Comments (5)
Sadly, the ESP32 toolchain doesn't include regex implementation nor fnmatch()
.
I don't want to bring in a regex library just for this as it would probably be overkill.
Perhaps we can simply use wildcard character, e.g. ?
and create out own MAC compare function. This wildcard would only handle a single character, not octet, to make things simpler and then you could configure:
"whitelist": [ "aa:bb:cc:??:??:??" ]
Does that sound reasonable to you?
from esp32-ble2mqtt.
Yes. That was my "regex like" function, the * or ?? does not matter me. Better the use of Wildcard as name. I fix the issue topic.
from esp32-ble2mqtt.
It may an easy implementation that replace the characters on the source mac addresses to ? on positions where the configurations contains them and only strcmp is required. Does it makes sense?
from esp32-ble2mqtt.
There is a proposal for wildcard support:
// The main function that checks if two given strings
// match. The first string may contain wildcard characters
int match(char *first, char *second)
{
// If we reach at the end of both strings, we are done
if (*first == '\0' && *second == '\0')
return 1;
// Make sure that the characters after '*' are present
// in second string. This function assumes that the first
// string will not contain two consecutive '*'
if (*first == '*' && *(first+1) != '\0' && *second == '\0')
return 0;
// If the first string contains '?', or current characters
// of both strings match
if (*first == '?' || *first == *second)
return match(first+1, second+1);
// If there is *, then there are two possibilities
// a) We consider current character of second string
// b) We ignore current character of second string.
if (*first == '*')
return match(first+1, second) || match(first, second+1);
return 0;
}
from esp32-ble2mqtt.
I saw that implementation when I was looking before. It seemed cumbersome and I'm not sure if it will handle multiple wildcards as expected. That's why I opted for a single-character wildcard. much more simple to implement.
The only reason I suggested the ?
is because it usually denotes a single character where *
is for zero-or-more characters.
from esp32-ble2mqtt.
Related Issues (20)
- Rate limit possible? HOT 3
- Issue trying to write characteristic to ThermoPro TP-25 HOT 8
- Unable to build HOT 6
- Switchbot meter broadcasters HOT 15
- What's the connection flow and how to control it? HOT 2
- /get and /set issues HOT 4
- How to set config.json can receive the encrypted broadcast advertise raw data? HOT 1
- Help needed: Vogel MotionMount not showing HOT 7
- Issuing commands to Opal Ice Maker HOT 3
- Connecting to a custom device is causing stack overflow crash HOT 5
- Setting values is not consitant HOT 10
- Maintain BLE connection on WiFi disconnect HOT 5
- Support repeating UUIDs HOT 7
- Ask for custom code/job HOT 1
- ESP32s3 HOT 5
- Configure Scanning? HOT 3
- BLE Advertisment publishing? HOT 3
- bug in ble2mqtt_task() function HOT 1
- How to Pair? HOT 1
- BLE Scan / certain broadcasters crash device HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esp32-ble2mqtt.