A while ago I was playing around with libble++[0] to read the data from some cheap temp/humidity sensors which broadcast their data as an advertising packet. Pretty simple, considering.
Did some other playing to turn my laptop into a BLE beacon (which worked pretty well with some random app on my phone) and also tried (IIRC successfully) to emulate one of those apple airtags though that code is lost somewhere on said laptop.
A quick glance at my temperature reading code and I'd say that counting the number of seen advertisements would be trivial using that library, I'm currently letting it do all the real work and just filtering the results to the devices I'm interested in.
[0] https://github.com/edrosten/libblepp
--edit--
I also seem to have started writing a python C wrapper around libble++ but obviously never followed through so its completeness is doubtful.