In this post we will enable Drakma HTTP support in the Android/MOCL example code. I have forked the repo on Github for posterity. The first post is here and it will get you set up with the Android/MOCL example without Drakma.
First we must download dependencies.
Drakma USocket Flexi-Streams Chunga CL-BASE64 Puri
My libs are located in mocl/systems. So I that’s where I place the folders of code, then link the .asd files. The instructions may change slightly with different versions of libs.
cd mocl/systemsln -s drakma-1.3.7/drakma.asd drakma.asdln -s usocket-0.6.1/usocket.asd usocket.asdgit clone https://github.com/edicl/cl-ppcre.gitln -s cl-ppcre/cl-ppcre.asd cl-ppcre.asd
Note that cl-ppcre-unicode.asd
also exists. Also of note
is the version of trivial-gray-streams
in use here. As of
this writing the current version is causing issues and the
version presented below should be used.
ln -s flexi-streams-1.0.12/flexi-streams.asd flexi-streams.asdgit clone https://git.gitorious.org/trivial-gray-streams/wukix-trivial-gray-streams.gitln -s wukix-trivial-gray-streams/trivial-gray-streams.asd trivial-gray-streams.asdln -s chunga-1.1.5/chunga.asd chunga.asdln -s cl-base64-3.3.3/cl-base64.asd cl-base64.asdln -s puri-1.5.5/puri.asd puri.asd
So after doing the linking dance we can uncomment the Drakma code in app.lisp (5 lines):
(pushnew :drakma-no-ssl *features*)(require :drakma)
(declaim (call-in net-test))(defun net-test ()(print (drakma:http-request "http://wukix.com")))
but we have to change out http://wukix.com
because as of
this writing wukix has changed their site to redirect to
https, and drakma can’t use ssl yet. In my case I changed it
to http://www.cliki.net/
because it currently accepts over
http.
and add net_test
to our MainActivity.java
. In this case
we just log out the result
CL.cl_init();try {String dataDir = getDataDir();CL.set_temp_dir(dataDir);CL.set_doc_dir(dataDir);CL.set_font_path(getAssetPath("DejaVuSans.ttf"));CL.load_contacts();} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}Log.e("CL",CL.net_test());
and run:
cd mocl-example-lisp-contacts-androidmocl --android LispContacts app.lispcd LispContacts/jnindk-build
Then simply debug the project in ADK and watch the logcat
output. The result should show up as an error, since we used
Log.e("","")
, with a tag of CL.