Messaging and changes to support discovery

These commits contain the messaging framework, and changes to ConnectThread and AcceptThread to support the new discovery process.