In the past week i have been testing sensors for the wine monitoring use case, since our pH probe broke, i am waiting for a new one to arrive and a humidity sensor. This probe will have: c02, alcohol, RH (relative humidity), temperature and pH sensors. Maybe in next week i will create a post about the probe. Until then, i have returned to my report, starting with tests. For now i completed Reliability and Performance tests for publishing data and notifications.

Results:

Since the fail rate was to high in POST, i found the problem was related to C command line tool "sawa_publish", which publishes the POST data to XMPP.

pthread_mutex_lock.c:87: __pthread_mutex_lock: Assertion `mutex->__data.__owner == 0 failed.

After looking at google, i did not find any usefull/clear solution, so i decided to simplify the publish function and repeat the same process when fails.

  • added a new publish function

  • removed variable and data arrays

  • added repeat process when fails, up to 3 times

function publish2()
{

    $this->form_validation->set_rules('USERNAME', '', 'trim|required');
    $this->form_validation->set_rules('USERPASSWORD', '', 'trim|required');
    $this->form_validation->set_rules('NODE', '', 'trim|required');
    $this->form_validation->set_rules('VARIABLEID', '', 'trim|required|numeric');
    $this->form_validation->set_rules('DATA', '', 'trim|required');

    if($this->form_validation->run()){

        $res=0;
        $count=0;

        while(!$res && $count <=2){
            $res=$this->sox_wrapper->publish(
                            $this->input->post('USERNAME'),
                            $this->input->post('USERPASSWORD'),
                            $this->input->post('NODE'),
                            -1,
                            -1,
                            $this->input->post('VARIABLEID'),
                            $this->input->post('DATA')
            );
            $count++;
        }

        if($res)
            echo "OK\n";
        else
            echo "FAIL\n";

    }else{
        echo "FAIL\n";
    }

}

Bash script example to upload data via HTTP POST (useful for resource limited devices)

#!/bin/bash

# settings
USERNAME=user123@hci.uma.pt/scripts
USERPASSWORD=pass123
NODE=testnode
VARIABLEID=23

URL="http://dev.hci.uma.pt/sawa/xmpp/publish2"
DATA=1

for ((  i = 1 ;  i <= 10;  i++  ))
do
  DATA=$i;
  curl -X POST --silent --data-binary "USERNAME=$USERNAME&USERPASSWORD=$USERPASSWORD&VARIABLEID=$VARIABLEID&NODE=$NODE&DATA=$DATA" $URL
done

Updated table with new code changes