The cyberphysical systems of smart cities are facing increasingly severe attack situations, and traditional separate protection methods are difficult to effectively respond to. It is urgent to coordinate public safety and cybersecurity protection. However, the integration of the two faces many challenges and is a very promising research field. The aim of this study is to investigate technical approaches for the synergy between public safety and cybersecurity. This paper proposes a smart city safety protection model inspired by the human immune mechanism. It was found that through a three-line defense architecture similar to the human immune mechanism, and with the help of certain algorithms and functional middleware modules, public safety and cybersecurity protection components can be dynamically combined to achieve collaboration. This work has verified through experiments a valuable path to effectively resist complicated attack threats intertwined with public safety and cybersecurity factors.