Monday, February 20, 2017

SMA Q2 extracting data.

SMA Q2 extracting data.


See my SMA-Q2 first impressions and do-not-disturb-automation blogs about SMA Q2.

SMA Care 

SMA Care app fetches Activity and Sleep data from SMA Q2 watch and store them in SQLITE3 database.

SMA Care:                                         Detailed HR data:                             Detailed Sleep data:     
Data are stored in a very light text based server less database: SQLITE3. 
Sqlite is very popular in android apps because data can be handled with standard SQL commands.
Fast and efficient way to store recurring data.

Place of databases:

You can find SMA Care application files (config files and data) on your Android device root directory: 

/data/data/com.szabh.sma_new/

The databases are here:     /data/data/com.szabh.sma_new/databases























Copy these database files to your SDCard and send to your PC.
I copy databases directory to SDcard with Tasker :



Then I send this directory to my NAS storage server with SCP.
See detailes here.
Copy databases to PC to further export and analysis.

Python for data analysis

Python is very popular language for data analysis.
You will soon understand why?

Database read with Python:

import sqlite3
import pandas as pd
from sqlalchemy import create_engine
db=sqlite3.connect('python/sma/mydb') # data/data/com.szabh.sma_new/databases
engine = create_engine('sqlite:///python/sma/mydb')


Read Table names from Database:

df = pd.read_sql_query('SELECT * FROM sqlite_master WHERE type="table" ', db)df.head(6)                                                                                                                            # List tables in database.


Export all tables to CSV:

tables=['Sport','Sleep','HeartRate','Alarm']
for table in tables:
    df = pd.read_sql_table(table, engine)
    df.to_csv(table+'.csv')

You will find 4 CSV file in your home directory

  • Sport.csv
  • Sleep.csv
  • HeartRate.csv
  • Alarm.csv
for example HR data seems like this:



Sleep data sample:



CSV




I also made data export in python.

df = pd.read_sql_query('SELECT * FROM Sleep WHERE date like "2017-02-18%" ', db)
df.head(5)



Python chart example:




Sunday, February 19, 2017

SMA Q2 - Do Not Disturb - Automation.

SMA Q2 and Do not Disturb Automation.


See my previous blog about SMA Q2.


You need Root access to your device to this!!

Do not Disturb (DnD) is a feature to enable or disable Notifications on watch. 
Watch is vibrate and display when any notification sent from phone to watch.

DnD settings is not available on the watch but can be set in the SMA Care app here:
The settings is unfortunately has no a Broadcast Intent. (you can't call directly) 

Why it is a problem?  Because when you forget to set DnD when go to sleep, then night messages or calls will be vibrate watch and will wake up you.

But DnD setting can be hacked with Tasker (An automation tool for Android) and Secure Settings (Secure Settings is also an android app which access system settings) 

The main principle is to deactivate Notification Listener service for SMA Q2.

What you need:
  1. Root on your device.
  2. Tasker 
  3. Secure Settings.   (as a Tasker plugin.)


  1. Make new Task 1   - name it ex.: SMA_notification_off.

2. Add Plugin - Secure Settings

  • All Action- 
  • System+ Actions
  • Notification Listener.
  • Choose SMA CARE in pull down list.
  • Disabled
  • Save.




3. Make another new (Task 2)   - name it ex.: SMA_notification_on.
    In this task set ENABLED the Notification listener.



4. Set a Tasker Profile.

Add a new Time based Profile in Tasker.
Ex: 21.30 -08:30
       Enter task is the TASK 1 (SMA_notification_off)
       Exit task will be TASK 2 (SMA_notification_on)


Try.

Enjoy.  :)

SMA Q2 - E-paper display watch


SMA Q2 is a Pebble Time like reflective display watch.

(SMA Time also used)


It means display is always on.


Color E-paper (E-ink) like display watch.  Basically it is a color LCD display with a good angle view.

It has lot of potential - depends on Support from SMA - the watch maker company.

Some feature highlights:

  • Always on - don't need back light to see display!
  • 40 days with one charge. (promised by company)
  • HR sensor for Heart Pulse measurement.
  • Accelerator sensor for Activity and Sleep measurements.
  • Vibration notification for any notification. ex: Calls, any notification from any app like messages, email, etc.
  • Back lights.

I can compare to Mi Band 2 because I earlier have that one, and can say it is comparable quality and much more useful because of "LCD" display.

If you have Pebble Time you fill this Q2 is ccomparison lone of that.

Strengths:
Could see the display any time (in any lighted environment)
40 days with one charge.
Cheap 48-55 USD. see Gearbest or Aliexpress.
Watch faces can be changed.
Hack-able in some basic aspect, like
Do not Disturb can be automated (see this DnD related blog) and planed to make blog for
HR and Activity data can be extracted (see sma-q2-extracting-data blog),

Weakness:
No custom watch faces yet! Most of the factory watch faces are ugly, un useful.
No support from company to development or community.
Relative big compared to Mi band 2.

See my comparison video of SMA Q2 to Miband 2

References:
XDA-developers forum
Italian review
Hungarian forum






Sunday, October 11, 2015

QI Charge for any Android phone ~ 8 USD

QI Charger for Doodgee Valencia DG800


My wife always had trouble with charging mobile Phone. Always forget exactly. :) (I love You honey, sorry for not hide you anymore in this... :) )

So I had to resolve the problem as engineer...

Solution is Wireless Charging. It is so cheep now, you can miss it.

But the problem is:
Wireless charger is not available for DG800!
However you can buy Universal QI Receiver for any Android devices like this from Ebay. (~ 3 USD.)

New-Qi-Wireless-Charging-Receiver-Charger-Module-For-Universal-Android-Micro-USB
3USD. Universal QI receiver from Ebay.

Remove your Phone back cover and put the Universal QI Receiver on top of your battery.
The QI receiver flexible cable must be connect to USB port of your Mobile:A(z) Screenshot_2015-10-11-19-56-28-1.jpg megjelenítése
QI Reciver connected to Phone USB.

Put Phone back cover on top the QI receiver. I had to make a little correction about the USB hole -make it bigger- to fit USB connector.
See picture:

A(z) 20151011_195443.jpg megjelenítése

Q:Where it is getting power?
A: From the air. (almost. :)

You have to buy QI Charger pad like this for ~ 4 USD.



Give power to QI Charger Pad and put QI Receiver (bundled to Phone) on top the QI PAD and charger LED will be Greeen and Phone get start to charged.

Current:
Im engineer - sorry for detailes:
Doodgee Valencia charges 660 mA with USB direct, and will charge 440mA with this set up.

Charging time:
QI charger takes 1/3 times longer than direct USB charge, but it worst.

Leave a comment, and see my other posts.


Friday, April 4, 2014

Chess on Kindle 4 - open-source

Chess on Kindle 4

K3Chess - free open-source chess for Kindle

Do you belive or not but there is a very good graphical chess on Kindle 4 NT (non touch).
It is free!

Check this:
http://www.mobileread.com/forums/showthread.php?t=152815


Amazing program, a very good example of masterpieces of opensource world. :)

E-ink is good for eyes, while you nut-cracking.

The chess is strong, it always wins over me. :)


MC on Android
:)

https://play.google.com/store/apps/details?id=com.nativnux.installers.mc&hl=hu

Midnight Commander Installer - screenshot

Tuesday, February 25, 2014

Call Record on Fritz.Box

Call Record - Fritz.Box 



I want automatic calls record on Fritz.box. After few days of Goggling found a solution :)

a few options: 

  1. On new (7320) Fritz devices provides this feature out of box. But it has many limitations; 
  • it is only for 10 minutes.
  • Not automatic, each call records must be allowed with key presses during the calls.
     2. Asterix PBX + Freepbx.
  • needs compilation, configuration and massive PBX knowledge. Probably uses lots of resources on HW side and from human side too... :)
Solution is

     3. FritzCap.

http://www.ip-phone-forum.de/showthread.php?t=232682
This is the call record solution on server side.
  • Download Fritzcap 2.0.0 (or 2.1 depending on your firmware)
  • Extract it, and configure-only the password in fritzcap.conf 
  • pick up the fritzbox handset and dial #96 * 5 * 
  • python fritzcap.py -c -d -m
thats all! Your all calls are recorded automatically.

Make it permanent:

make a shell script in /etc/init.d directory.



#touch /etc/init.d/fritzcap

edit file and insert this
python /yourroute/fritzcap.py -c -d -m
Save file.

#chmod +x fritzcap
#update-rc.d fritzcap defaults
#sync
#reboot
check it is runing:
#ps ax | grep fritzcapHauskeeping script.

# ps ax | grep fritzcap
 1817 ?        S      0:00 /bin/sh /etc/init.d/fritzcap start
 1822 ?        Sl     0:08 python /usr/local/bin/fritzcap.py -c -d -m
 2171 pts/1    S+     0:00 grep fritzcap
Hauskeeping script.

Cap and Wav files are large, convert mixed wav to mp3 and delete all source files.
Convert to mp3 with CRON. for example in the night when system not loaded.

# crontab -l
to check present cron

Just edit crontab.
# crontab -e
30 2 * * * /usr/local/bin/wav2mp3.sh

# cat wav2mp3.sh                                                                                                      

#!/bin/sh
# wav to mp3
cd /usr/local/bin/captures
nice -19 find /usr/local/bin/captures -name '*mix*.wav' |
while read i
do
if [ ! -f ${i%.wav}.mp3 ]; then
    nice -19 lame -h -b 128 "$i" "${i%.wav}.mp3"
fi
done
cd /usr/local/bin/captures
nice -19 find /usr/local/bin/captures -name '*.mp3' |
while read i
do
FILESIZE=$(stat -c%s "$i")
if [ "$FILESIZE" -gt 1000 ]
then
    nice -19 rm -f ${i%_mix_0_1.mp3}*.wav
    nice -19 rm -f ${i%_mix_0_1.mp3}.cap
fi
done

#repair cap file:
#python /usr/local/bin/fritzcap.py -d /usr/local/bin/captures/2014-03-10/160627/capture_20140310160627.cap