From your question I can’t tell if you got the sample to work, then it failed when yopu added security, or if you are experiencing repeated connect/disconnect problems.
If the connection is repeatedly connecting and dropping, one of your passwords may be incorrect. Another possibility is that there is a setting on one or both of the routers that is rejecting the signal because of a MAC address issue. A sort of “white list” of accepted MAC addresses on an Cisco WAP was causing a similar problem for me. The computers would connect, then disconnect again and again. Try your configuration without any security enabled (remove sensitive systems from the network before doing this), if you get a reliable connection, check that your passwords, encryption methods (for example TKIP or AES…) and MAC filters match for both pieces of equipment. Adding one “piece” of security at a time should help with your troubleshooting.
More details of your problem might help others or myself give a better answer.
Another thing to check would be if either device has a built in clock that the times are the same. time differentials can cause problems with some encryption systems.