Secure topology maintenance and events collection in WSNs