Added the code to wrap peripherals
Added common functions file and the event handler/chat event loop to main