Author Archives: admin

About admin

IT consultant.

Presenting SmartBand 2 steps on your own website

This guide will show how to fetch logged data from Sony SmartBand 2 and present it on a website. Sony has recently released a heart rate monitor called SmartBand 2. The SmartBand 2 is compatible to both Android and iOS. The SmartBand 2 app can store all activities in Sony Lifelog which provides a REST API that makes it possible to receive all logged data.

What to do

There are some steps to do in order to present the data on a website. The steps are:

  • Setup the SmartBand 2  (Buy a SmartBand 2, install the host app, create a Lifelog account and add it to the app, take a walk in order to log some steps)
  • Register for a free PHP web server account
  • Upload the Lifelog PHP library to the webserver
  • Create a Lifelog app account
  • Download and configure a Lifelog PHP library on the web server

Setup the SmartBand 2

If you’re using Android (which this guide cover), do the following:

  • Download SmartBand 2 and Lifelog
  • Open Lifelog and create an account
  • Open SmartBand 2 and pair your band with the phone
  • When the band is paired and upgraded with the latest firmware, add your Lifelog account to the SmartBand 2 app aswell
  • Configure example Lifelog

If you need more help, please read the user guide.

Register for a free PHP web server account

Now it’s time to develop a web app that can present the steps. I have only found one PHP library for Lifelog and it is Google APIs Client Library for PHP with Lifelog. It’s written in PHP so the webserver need PHP support.
Go to BYET Internet Services and register a free account. This web host provider supports HTTPS which is needed by Lifelog.

Upload the Lifelog PHP library to the webserver

Google APIs Client Library for PHP with Lifelog can be downloaded as a zip from here. Download it, extract it and upload the extracted files to your website through FTP. FileZilla is a good free FTP client.
This guide will use the example in folder /examples/lifelog. And to make it work Lifelog client account data is needed to be inserted into lifelog_config.php.

Create a Lifelog app account

Go to Lifelog API admin page and register an app. E.g.:

  • Application name: MyStepsWebApp
  • Callback URL: https://lifelog.byethost5.com/src/examples/lifelog/callback

The Client ID and Secret you got will be used in next step.

Configure example Lifelog

Open the src/Google/examples/lifelog/lifelog_config.php in a text editor and change the Client ID and Secret to the values recevied in the Lifelog admin page.

Run the example

Now run the example (in this guide https://lifelog.byethost5.com/examples/lifelog/). Click on the “Add my Lifelog account” link and follow the guide with the same account as you used in the SmartBand 2 and Lifelog-app.
After has been authenticated, you should be able to see your steps.

Add code that show SmartBand 2 steps

Pase the in code below on line 181 (just before echo “</pre>”;):



    if ($listDataSources == NULL) {
		//Fetching data sources failed above
		$listDataSources = $dataSources->listUsersDataSources("me");
	}
    echo "
Getting SmartBand 2 steps from data sources
"; //Setting filter paramters $params = array( "start_time" => "2015-11-10T09:00:00.000Z", "end_time" => "2015-11-16T09:00:00.000Z" ); $params = array(); $dataArray = $dataSources->get("me", "activities", $params); //Print array (or loop through it) $results = get_lifelog_results($dataArray); //print_r($results); $day_steps = 0; $current_day = 0; foreach( $results as $r) { if (is_source_name($r, "swr12")) { $start_time = clear_time($r['startTime']); if ($current_day == 0) { $current_day = $start_time; } $day_steps += sum_steps($r); if ($current_day != $start_time) { //New day echo "
steps: " .$day_steps; echo "\tday: " .$current_day .", " .gmdate("Y-m-d\TH:i:s\Z", $current_day);; $day_steps = 0; } $current_day = $start_time; } }

And at the end of the file just before the ?>, add the following help methods:


function clear_time($timestamp) {
	$date = new DateTime();
	$date->setTimestamp(strtotime($timestamp));
	//Clear hour, minutes and seconds
	$date->setTime(0,0,0);
	return $date->getTimestamp();
}

function get_lifelog_results($data_source) {
	if(isset($data_source) && isset($data_source['modelData']) &&
	isset($data_source['modelData']['result'])) {
		return $data_source['modelData']['result'];
	}
	return null;
}

function is_source_name($result, $name)  {
	foreach($result['sources'] as $r) {
		if (strcmp($r['name'], $name) == 0) {
		    return TRUE;
	    }
	}
	return FALSE;
}

function sum_steps($result) {
	$sum = 0;
	foreach($result['details']['steps'] as $steps) {
		$sum += $steps;
	}
	return $sum;
}

Run the example again and at the end of the page, you can now see your steps that were registered by your SmartBand 2.
Feedback and comments are welcome.

Have fun with Lifelog and your SmartBand 2!

ERROR – AppleUSBEthernet: monitorLinkStatus – Link partner register is bad

Problem
After system update to Mac OS X 10.7.5 (or as other users have reported 10.7.4) the Apple USB Ethernet adapter may stop to work. When plugging the Apple USB Ethernet adapter into the MacBook it will not communicate on the network.

Symptom
The terminal command ifconfig show the ethernet adapter but without IP address.
The terminal command sudo dmesg will show the following:

AppleUSBEthernet::monitorLinkStatus – Link down, Device a861500
0 0 AppleUSBEthernet: monitorLinkStatus – Link partner register is bad, re-trying…
0 0 AppleUSBEthernet: monitorLinkStatus – Link partner register is bad, trying to reset…
AppleUSBEthernet::monitorLinkStatus – Link down, Device a861500
0 0 AppleUSBEthernet: monitorLinkStatus – Link partner register is bad, re-trying…
0 0 AppleUSBEthernet: monitorLinkStatus – Link partner register is bad, trying to reset…

Solution
It seems to be the driver for the Apple USB Ethernet adapter that is the problem. Download the latest from ASIX Electronics. Install it and restart the computer.

Product family: USB 2.0 to fast Ethernet
Product name: AX88772

URL: http://www.asix.com.tw/download.php?sub=downloadsearch&PSNoID=101.

Good luck!

Best regards Mikael Johansson, ComplexIT

ERROR – Acronis Backup & Recovery 10 Management Console install XRender

Problem

When trying to run Acronis Backup & Recovery 10 (e.g. from the desktop icon or from terminal), a popup window displays the following error message: “To be able to run Acronis Backup & Recovery 10 Management Console install XRender Library on the machine.” Even when libXrender-0.9.1-3.1.i386 is installed.

Verified on:

  • Installation file: BackupRecoveryServerLinux.11345_s_en_.i686 (Acronis True Image Echo Server for Linux, Acronis Backup&Recovery Server for Linux Upgrade)
  • Kernel: 2.6.18-8.el5xen #1 SMP Fri Jan 26 14:42:21 EST 2007 i686 i686 i386 GNU/Linux
  • XRender: libXrender-0.9.1-3.1.i386

Acronis Backup & Recovery 10 Management Console install XRender

Solution

Acronis support says that the problem is related to the video modules that is used by their software and a fix will be available in a month (in February). Until then, it’s possible to use the trueimagecmd command line tool (see User’s Guide).

References

VxWorks & Qt – Relocation value does not fit in 24 bits

Problem

When loading Qt with VxWorks with a PowerPC CPU the following error messages can appear:

Relocation value does not fit in 24 bits (offset: 0x19c948, type: 10)
Relocation value does not fit in 24 bits (offset: 0x19ca20, type: 10)
Relocation value does not fit in 24 bits (offset: 0x19d91c, type: 10)
Cannot load library /tffs0/libQtCore.so

This happens when Qt, VxWorks or an application is not compiled with the -mlongcall flag and when the libraries/files that are loaded into memory comes to far away from the VxWorks kernel. This only affects computers with more than 32 MB of RAM. The PowerPC relative branch instruction is limited to jumps between +/- 32MB (24 bits = +/- 4M instructions, 4 bytes per instruction = +/- 32MB) of the current instruction. If an instruction cannot be resolved within a 24 bit range, it will print out the error above.

Solution

Compile the software with the -mlongcall flag. The compiler flags are located in the mkspecs\unsupported\vxworks-ppc-g++\qmake.conf file. No Qt version so far has the -mlongcall flag, so it must be added manually. It’s important that VxWorks (including the stdlib), Qt and your application is compiled with -mlongcall.

If VxWorks’ stdlib is not compiled with -mlongcall and the source code is not available, disable it with the -nostdlib flag. This means that you cannot use the stdlib API. Instead replace the stdlib functions with the corresponding functions in Qt.

More information about this will soon be posted (e.g. a working qmake.conf file for VxWorks).