Security analysis and intrusion detection for embedded systems : a case study of smart meters