Sample cURL application built using CLI tools

This article shows how to build sample application based on url2file cURL demo using command-line tools.

Prerequisites

  1. It is assumed that you have already installed Samsung Customized Emscripten SDK as described in WebAssembly/Getting Started

  2. You have installed either Tizen Studio or Tizen Studio with CLI(command line interface). See Quick-start Guide.

Step-by-step guide

  1. Download url2file.c.

    Note

    You can also clone whole repository from github.com.

  2. Download CA certificates extracted from Mozilla:

    curl -O https://curl.haxx.se/ca/cacert.pem
    
  3. Compile url2file.c demo

    emcc -o url2file.html -s ENVIRONMENT_MAY_BE_TIZEN -s USE_CURL=1 --proxy-to-worker --preload-file cacert.pem url2file.c
    
    Option Description
    -o url2file.html Name of the output, this will make that Emscripten will generate url2file.wasm, url2file.js and url2file.html
    -s ENVIRONMENT_MAY_BE_TIZEN Flag indicating that we want to use Samsung Tizen Emscripten extensions available on Samsung Smart TV. This flag is necessary to use POSIX sockets APIs in your application.
    -s USE_CURL=1 Flag indicating that we want to build and use cURL library provided with Samsung Customized Emscripten. Note that during 1st build full library is being built, so compilation may take a while. However after 1st build cURL library is cached. See more on details on Emscripten Ports
    --proxy-to-worker This flag is needed to run main() function of your application in a Web Worker, because Samsung Tizen Sockets Extensions can only be used in a Web Worker.
    --preload-file cacert.pem This option allows your application to read cacert.pem file using standard C APIs fopen(./cacert.pem)

    Implicitly enabled options:

    Option Description
    -s USE_SSL=1 Flag enabling SSL library (libssl) from OpenSSL libraries. This flags is implicitly turned on by -s USE_CURL=1
    -s USE_CRYPTO=1 Flag enabling use crypto library (libcrypto) from OpenSSL libraries. This flags is implicitly turned on by -s USE_SSL=1
    -s USE_ZLIB=1 Flag enabling use of zlib compression library. This flag is implicitly turned on by -s USE_CURL=1

    Further information regarding Emscripten build options can be found on Emscripten Compiler Frontend (emcc)

  4. Download config.xml to the same directory where the demo was built.

    Note

    • this application needs http://tizen.org/privilege/internet privilege
    • content src attribute points to "url2file.html" instead of standard index.html, as this is what was generated by emcc.

    More information regarding the config.xml file format can be found on Developer Samsung

  5. Sign and pack widget using Tizen CLI interface:

    tizen package -t wgt -s <YOUR_CERTIFICATE_PROFILE_NAME> -- .
    

    Guide showing how to create certificate profile can be found at Creating Certificates

    More information regarding Tizen CLI interface can be found at Command Line Interface Commands

  6. Set your TV into developer mode as described in TV Device

  7. Connect to the TV using sdb:

    sdb connect <TV_IP>
    

    SDB command and its options are described on Connecting Devices over Smart Development Bridge

  8. List connected devices:

    sdb devices
    

    Sample output:

    List of devices attached
    192.168.13.2:26101      device          0
    
  9. Install widget on the TV:

    tizen install -n url2file.wgt -t 0
    
    Note

    In option -t 0 value 0 is taken from last column of sdb devices
    command output.

  10. Run widget on the TV:

    tizen run -p url2file00.curl -t 0