What was the last thing you did before it happened?
In safe mode, the computer runs using only all the generic drivers that came with the PC ( hardware upgrades will not be accessible). If you installed or updated the driver for your network controller, you might wanna try uninstalling the driver from Device Manager then reboot the PC and let it find a driver by itself. If that didn't work, install the latest driver that you have just downloaded. Hopefully it is just a corrupt driver issue which is what code 31 is all about.
Can you post a screenshot of your network and sharing center screen?