Closed justcallmekoko closed 5 years ago
I found that the issue seems comes when two separate callbacks to the sniffer_callback function attempt to add to the list at the exact same time.
Edit: I take back what I said. If I comment out the Serial.println(list->shift());
line and keep all of the lines where the list is added to, there are no issues. The issues only happen when I am shifting the list WHILE adding to it.
Sorry mate! For some reason I wasn't watching this repository, so I didn't get a notification.
What you're describing sounds like a synchronization issue. Something you can maybe fix by setting a semaphore. You might have to drop a packet from time to time though.
Do you still need assistance?
I would recommend to use std::list whenever possible, or LinkedList. Although I wrote this to improve the LinkedList library, it's more tested and this repo isn't really of any use to me anymore.
No problem at all. I figured this repo wouldn't get too much attention considering the reason you made it in the first place. I had considered using LinkedList but I wanted to see if I could get this working first. I did end up using a binary semaphore but it isn't perfect. In a busy apartment complex with many WiFi APs, the beacon sniffer will run for about 30min before crashing (even with semaphore). I probably need to tune it a little bit and like you said, probably drop some packets.
It isn't perfect but it is close. The annoying part is that I am only using the list as a print buffer because the screen is a touch screen and cant print and touch at the same time because of SPI. I have to check for screen touches THEN print from the strings loaded in the list.
Thank you so much for the suggestions and taking time to check on my issue.
I have a WiFi sniffer code that sniffs out beacon frames.
I have a SimpleList that stores strings to be printed to the screen
SimpleList<String> *list = new SimpleList<String>();
In the sniffer callback function, I am:
list->add(bssid_essid_string)
In the main loop of the code, I am:
list
to the screen usingSerial.println(list->shift());
As you mention in your README, this should return and remove the first item from the list and it does.The code runs fine until it cycles to a channel(1, 6, or 11) where there are A LOT of beacon frames. Typically once it gets to channel 11, it prints dozens of beacon frames then crashes saying CORRUPT_HEAP. It doesn't happen at the same time every time. It may run for 5 seconds then crash, or 15 seconds then crash.
My first assumption is maybe a condition where the the sniffer callback it attempting to add to
list
while the main loop is trying to shift thelist
.