iists IT


slinks, laisks un kārs uz halvu

Problēmas risināšana IT stilā

Kā vienmēr, vāros gari, TLDR: Asterisk.

Bitei ir laba zona, teikšu ka pat labāka kā Tele2. Bet ne visur. Un ne vienmēr. Teiksim kabinetā man neiet, it kā ir, bet tā -tā. Labā lieta ir tāda, ka parunāt var, bet reāli jau neviens nerunā kabinetā (lai netraucētu kolēģiem), tapēc dodas ārā. Parasti klusākā vieta kur nolīst ofisa ēkai ir tuvāk pilsētas centram, tur arī zona ir krietni labāka, ideāla.

Tā sanācis, ka pēdējā laikā biežāk sēžu kabinetā stāvu zemāk. Tur Bitei man zonas nav pilnīgi necik, nepalīdz nekas, ne forsēts 2G, nekas. Sanāca pat tā, ka kolēģis ar LMT regulāri nāca lejā, iedot telefonu parunāt, jo klients mani nevar sazvanīt. Un ja klients nevar sazvanīt, tad tas ir slikti. Neskatoties uz to ka mūsu ofiss atrodas Valmieras baltajās zīmēs, sajūta tāda kā dzīvotu trešās pasaules valstī. Vienkārši atrodamies pilsētas nomalē un ofisa ēka laikam ir viens liels faradeja būris kas nepatīk bites viļņiem.

Skatījos tarifus, bite tomēr uzvar, tieši tarifu ziņā. Tele2 ir laikam tik pat, bet minu ka Tele2 zona ir tāds pats craps. Un es vēl ļoti ilgi atcerēšos apjājienu ar Tele2 interneta tarifiem. Ja man būtu piektā nokija, tādas problēmas nebūtu, bet jau 10 gadus tālruņiem nav ārējās antenas.

Risinājumiem  bija dažādi, bet mans risinājums šai situācijai  ir tāds - Tā kā Android jau no 2.3 versijas ir native VOIP atbalsts, tad izlēmu būvēt telefoncentrāli. Paņēmu mājās veco raspberry pi, piespraudu tīkla vadu un no kolēģa aizlienētu "mobilo puļķi". Iekšā ieliku Okarti, tādas mētājas no dažādiem projektiem un uzstādīju  Asterisk atvērtā koda telefoncentrāli.

Protams tik vienkārši jau tas nebija, ņemot vērā, ka pieredze ar to ir ļoti ļoti minimāla (necik). Nekas tur negāja, kompilējot nekas negāja un likās ka tas ir absolūts no-go. Pat RasPBX īsti nesagāja uzreiz, bet ar laiku izdevās pielauzt un atkārtoti uzliekot vēl kādas 5 reizes, viss jau gāja pat ļoti raiti.

Sastāvdaļas - Android telefons, Raspberry Pi (der pirmais, pats senākais modelis), RasPBX, USB GSM modulis, Okarte un tīkla vads.

1. Android telefonam pievienoju savu telefoncentrāli kā SIP serveri (extension), ieslēdzu ienākošos zvanus, nodrošinot to ka centrāle mani var sasniegt jebkurā laikā.

2. Telefonam ar kodu *62* aktivizēju zvanu pāradresāciju uz sekundāro numuru laikos kad mans primārais numurs nav pieejams.

3. Centrālē USB puļķī ienākošos zvanus savienoju (trunk) ar savu centrāles numuru (extension) un zvani no sekundārā numura caur internetu nonāk pie manis. Aizmirsu pieminēt, ka (loģiski) kabinetā ir ļoti labs internets.

4. Zvanot kontaktiem, telefons ļauj izvēlēties kā vēlos zvanīt - caur primāro telefontīklu, vai SIP serveri. Tad kad nav zonas, zvanu caur SIP.

Tā kā viss patika, sākotnēji ieslēdzu arī zvanu ierakstīšanu, bet tā kā atvilnē atrastā SD karte bija veca un lēna, tad nebrīnos ka tieši tas bija iemesls tam, ka kādas pirmās 5 sekundes sarunā ir sarunas aizture uz kādām 2 sekundēm. Pēc tam viss ir kārtībā, aizturi, manuprāt, just nevar. Kad noņēmu ierakstīšanu, šāda aizture ir var būt sekundi vai divas pēc sarunas sākšanas.

Vēl viens sarežģījums radās, kad aizlienēto interneta puļķi nomainīju pret patstāvīgi, māsas doto. Abi ir huawei (chan_dongle prasība), bet otrais bija bloķēts. Pirmkārt, jānoņem SIM aizslēgu, bet pašu USB modemu var atslēgt, iegūstot kodu no IMEI numura (internetā atrodamas programmas) un ievadot to AT komandu veidā. Nesaprotu, kādēļ operatori tos vispār bloķē, jo atslēgšana aizņēma vien dažas minūtes.

Ja es pie šāda elementāra risinājuma būtu nonācis kādus 5 gadus atpakaļ, kad starp "lielākajiem" tīkliem nebija bezmaksas minūtes, varētu sev uztaisīt stipri lētākas sarunas, izmantojot vairākus puļķus un SIM karti katram tīklam. Tagad tas, protams, ir bezjēdzīgi, ja vienīgi noliek sev citu centrāli kaut kur ārzemēs, kur pašam sanāk biežāk zvanīt. Bet tam ir var ļoti ērti lietot zerozvanu.

Tā nu šoreiz esmu sadzīvisku problēmu risinājis nevis ar naudu (iegādājoties citu karti ar labāku pārklājumu), bet gan ar IT attapību ;)

Sadaļa

Lenovo S650 Lollipop

Good news, we have working Android 5 available for our phone, Lenovo S650. Of course it's third party again, but it works, there is no bloatware (besides google chrome) preinstalled so it's all good. And we have stock settings and Google Now Launcher by default. So far it looks clean and performant, no HW issues whatsoever. EDIT: not a real lollopop :(

Sadaļa

Lenovo S650 AOSP 4.4.2 (Kitkat) + common issues I've had installing it

Lenovo S650 is a great phone and I think it's newer brother, S660, is even better. There are only 2 real drawbacks:

  • it has no built in compass (which is really really bad)
  • it has very special software, VibeUI on it.

The VibeUI. It can very well be kitkat (yes, they do have official kitkat update now), but you wouldn't know that unless you look at the software version, because they have modified everything. Even settings menu is custom, I hate that. Another issue is that fishy antivirus thingy that keeps bugging me. It could run in background, but instead it's always on status bar. I hate that. I tried to escape it in any way, but there is no support, seems like everyone loves the VibeUI.

Last night I found out there is an AOSP kitkat version that actually works. So i've written a small article how I installed it on my S650, because this custom firmware is published on russian site and while i can somehow read it, i believe there are people that cannot.

First, here's a link to the forum topic that has various firmwares: http://4pda.ru/forum/index.php?showtopic=567114

IMEI backup

It's very possible that you will loose your mobile connectivity because of invalid IMEI error after flashing any firmware. You have to write down both IMEI numbers of your phone just to be safe. You have been warned. Do this first and save the numbers.

Custom recovery

You will need TWRP recovery for your phone. I got it from here: http://lenovo-forums.ru/topic/3499-lenovo-s650-%D1%80%D0%B0%D1%81%D1%88… (or here)

I had ROW version installed already because my phone was ROW.

Firmware

I chose "Google_AOSP by Zver999666", because it was latest that had all features i wanted. It's posted here: http://4pda.ru/forum/index.php?showtopic=567114&st=1380#entry35813841

There are 3 downloads: ROW version, CN version and Root that works on both. You have two options to choose from: ROW ROM or CN ROM, but you have to flash version that your current system has. I tried to run ROW, but I got stuck on a boot loop with coloured dots flying around, never finishing the boot.

ROW TO CN TWRP change

So what i did is, i changed TWRP from ROW to CN by flashing a new one and I also flashed filesystem fix rp_5.5+0.5gb-cn.zip, originally posted here, but the link didn't work so i got it from here: http://lenovo-forums.ru/index.php?app=forums&module=forums&section=atta… .

It  also comes with an instruction: you flash TWRP CN version (2.7), reboot and then flash the format.zip that has been automatically created in root of sdcard.

Then i flashed the rp_5.5+0.5gb-cn.zip mentioned earlier and it was all good now.

Flashing CN version

So yeah, I flashed the CN version, then Root pack and it just worked.

Invalid IMEI

This one has been bugging me from the very first night I got the phone and flashed it. I think i accidentally formatted the wrong partitions or something, but i had to fix IMEI. Apparently it was erased so I had to fix it somehow. IMEI1 is written on the back of the phone, I calculated another IMEI using online calculator (cannot recall which one), because you cannot just provide a random one. I used those 2 IMEI numbers and software called imei_mtk6515 (I know we have MTK6582, but it indeed works) from https://github.com/luckasfb/Fly_IQ255_Firmware_Build/tree/master/tools/…

You have to run it like this: imei.exe <15digit_IMEI_1> <15digit_IMEI_2> MP0B_001
I have linux, but the exe file still works even for me, so apparently it doesn't matter if you have windows or linux.

This command generates nvram file MP0B_001, that you have to put in /data/nvram/md/NVRAM/NVD_IMEI/ . To accomplish this, i used software called "ES File explorer" that has "Root browser" option which allows copying the MP0B_001 and putting it in location provided above.

One more thing: It didn't work for me at first, but i figured out i have to set permissions for the file, 660 (rw rw -).

Reboot the phone and you should have coverage now.

Sadaļa

EXIF rename

Atjaunoju sen pazaudētās bildes, bet tā arī nebiju sašķirojis. Uzmontēju mazu koda gabalu, kas tās vismaz sakārto pa mapītēm.

 

for file in atguutaas_bildes/*jpg
do
    # get date from exif
    dst=$(exif -t 0x9003 -m $file | sed 's/ /-/g' | sed 's/://g')
    dst_date=$(echo $dst | cut -d "-" -f 1)
    dst_time=$(echo $dst | cut -d "-" -f 2)

    filename="${file##*/}"
    newname=$dst_date/$dst_date-$dst_time-$filename.jpg

    # test for empty date
    if [ -z "$dst" ] 
    then 
        newname=$(basename $file)
    fi

    # create folder if doesn't exist
    if [ ! -d sorted/$dst_date ] 
    then
        mkdir -p sorted/$dst_date
    fi

    # move pics
    mv $file sorted/$newname
    #echo sorted/$newname

done

Sadaļa

Sweex LW150 firmware upgrade

Just like every other el-cheapo home wifi router i've had lately, this one (Sweex LW150) gave up too (of course only when warranty was over). Occasionally hanging up, quietly waiting for reset.  

I have TPlink lying around too, but it would be too fancy, having wifi router with a USB port. So I looked for firmware upgrades, but found none, even in sweex homepage. Googled firmware I was currently on (H1_V3.2.5e) and found, as it appears, an alternative device Tenda W268R.

Why would I even think of flashing different firmware in it? Lucky guess - I found this listing and assumed W268R is rebranded LW150. 

So yeah, i did flash it (not so much with fingers crossed, more with hope of getting new hardware) and it still works, just different Web-UI. Same settings, just like casual upgrade. Rebooted several times, reset to default config, reconfigured and will see how it acts during nightly data backup sessions.

TLDR: If you have Sweex LW150, you can upgrade it with firmware from Tenda W268R. Just look out for old firmware name, you gotta look out for correct prefix (H1_V3.xxx)

Sadaļa

How to fix low mic volume issue on Cubot GT99

Cubot GT99 is cheap yet beautiful quad core android phone from yet another Chinese manufacturer. Of course there's no support or anything for it and user base is low.

I struggled with this issue where other party was unable to hear me because my mic level appeared to be really low. There is no setting to change it. First i thought that might be faulty hardware or something, but it works okay when in speaker mode so i wanted to figure it out.

Phone is based on MKT (MTK6589) chip so we'll use Mobileuncle MTK Tools to boost mic volume.

1. Download application from Play Store: Mobileuncle MTK Tools

2. Open application, navigate "Engineer Mode > Engineer Mode ( MTK )", then swipe to "Hardware Testing" tab and open "Audio > Normal Mode"

3. Watch carefully for "Type", change to "Mic".

4. Change values for Level 0 to 6 one by one and don't forget to press "Set" after each change.

Note: for even louder mic, you can set all values to 255

Level 0 - 112
Level 1 - 136
Level 2 - 160
Level 3 - 184
Level 4 - 208

Level 5 - 232 
Level 6 - 255

After you've saved (Set) last setting, you may exit the application and everything should work. If you are like me and you want to see other settings too, go ahead. Just don't fiddle with them much as you can easily "break your phone" by changing wrong setting. 

btw, here's the easiest way to root cubot gt99 in case you need it. works both on windows and linux - http://blog.geekbuying.com/index.php/2013/07/31/how-to-root-cubot-gt99-mtk6589-quad-core-smart-phone/

Piezīme: Šis ir vēl viens angļu valodas ieraksts samērā retai problēmai, kurai internetā neradu risinājumu un atrisināju pats.

Sadaļa

Flash cl-osd into g-osd using usbasp S51 avr

I've had this g-osd for couple years already which lacked few features. There was very promising project coming up on rcgroups which stated that we'll be able to have better firmware for those el-cheapo OSD's.

CL-OSD project page

I have no experience with chip programming whatsoever so i thought this is going to be really complicated, keeping in mind that i have ubuntu linux computer.

So i bought this cheap programmer off ebay (more permananent link from dx instead) , called "USBASP USBISP Downloader Programmer for 51 AVR". Was really cheap, like 5$ shipped.

Use picture from project site (see G-OSD pic) as a reference to solder of wires in place. Test which is correct wire and solder down connector pins.

Download subversion if you don't have any
# sudo apt-get install subversion

Download latest cl-osd code:
# svn checkout http://cl-osd.googlecode.com/svn/trunk/

Install avrdude on ubuntu, like this
# sudo apt-get install avrdude

Then change into cl-osd directory
cd trunk

Note: if you plan changing anything, this is the source. Otherwise (and i suggest doing that for the first time, just change directory that contains pre-compiled binaries.
# cd G-OSD

Connect the programmer (and the OSD device), programm chip like this:
# sudo avrdude -p m88 -c usbasp -U flash:w:cl-osd.hex -U eeprom:w:cl-osd.eep

This didn't work out for me because of some errors, so i forced the flash:
# sudo avrdude -p m88 -c usbasp -U flash:w:cl-osd.hex -U eeprom:w:cl-osd.eep -F

Then some upload progress happened and less than minute later i was ready to hook it up to video link again. And it works!

Sadaļa

How to root Pipo M9 using Ubuntu Linux

 

Note: updated version of this article available on my other website, dedicated to pipo m9 device only: http://www.pipo-m9.info/

 

Was unable to get the windows driver working properly, so i gave Ubuntu 13.04 a shot at rooting Pipo M9 device.
We're running all commands as root, so start with "sudo su". Your prompt should start with "#" now. 

1. Download usual windows rooting archive from http://www.mediafire.com/download/dzx599tkq0rdehl/RK3188_ROOT_Tool.zip (zip password is "geekbuying.com".

2. Get adb. I didn't have one, so i installed it like this:
# add-apt-repository ppa:nilarimogard/webupd8
# apt-get update
# apt-get install android-tools-adb android-tools-fastboot

3. Make sure your computer can see device. Turn on "USB Debugging", connect usb cable and see dmesg output.
# dmesg
Should return something like this:
[45441.193934] usb 2-1.3: new high-speed USB device number 12 using ehci-pci
[45441.286976] usb 2-1.3: New USB device found, idVendor=2207, idProduct=0010
[45441.286983] usb 2-1.3: New USB device strings: Mfr=2, Product=3, SerialNumber=4
[45441.286987] usb 2-1.3: Product: M9
[45441.286991] usb 2-1.3: Manufacturer: rockchip
[45441.286994] usb 2-1.3: SerialNumber: KI8VAVXFUD

4. Get the udev rolling
# sudo gedit /etc/udev/rules.d/99-android.rules
paste this text: SUBSYSTEMS=="usb", ATTRS{idVendor}=="2207", ATTRS{idProduct}=="0010", MODE="0660", OWNER="root"

# service udev restart
# udevadm control --reload-rules
# echo "0x2207" > ~/.android/adb_usb.ini

5. Hopefully adb can see device now (fingerscrossed)
# adb kill-server
# adb devices 
Should return this:
List of devices attached 
KI8VAVXFUD device

6. Explore the RK3188_ROOT_Tool zip you downloaded and extracted earlier, move into directory
#  cd /home/janis/Downloads/RK3188-root
Pay attention to TPSparkyRoot.bat file, you should open it in text editor and execute it line by line (following the directions in echo parts of code). 
After you run the commands listed in bat file, your device should be succesfully rooted and your tabled should have new icon (SuperSu app) on home screen.

 
Ierakstu izdomāju uzbakstīt angliski, jo man neizdevās atrast risinājumu šai problēmai. Iespējams kādam citam noder. 

Sadaļa

Dārznieks, lol

Notikumi tā sakrita, ka iegādājāmies pāris jaunus telpaugus, jo iepriekšējie bija beiguši savu dzīvi (gadās). Apņēmības pilns, nolēmu tos šoreiz neaizmirst uz pus-gadu podiņos, paņēmu no plaukta arduino, iespraudu puķu podā pāris spailes un sāku veikt mērījumus (pretestību).

Teorētiski viss vienkārši - mitrums = maza pretestība; sausāks = lielāka. Nodomāju ka jāsāk ar empīrisko datu ielasīšanu, jānoliek to visu stacinoāri. Lai padarīto to visu mobīlāku, iegādājos TPLINK (MR3420 v1.2) bezvadu rūteri ar USB portu, arduno pievienošanai. Pirms iegādes noteikti jāizpēta, lai rūterim derētu openwrt vai ddwrt firmware. 

#include "DHT.h"
#define DHTPIN 3
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
const int PROBE = A0-A4;
int powerPin = 2;
void setup() {
  pinMode(powerPin, OUTPUT);
}
void loop() {
  Serial.begin(9600);
  dht.begin();
  digitalWrite(powerPin, HIGH);
  delay(100);
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  // check if returns are valid, if they are NaN (not a number) then something went wrong!
  if (isnan(t) || isnan(h)) {
    Serial.print("0,0,");
  } else {
    Serial.print(h);
    Serial.print(",");
    Serial.print(t);
    Serial.print(",");
  }
  Serial.println(analogRead(A0));
  digitalWrite(powerPin, LOW);
  Serial.end();
  delay(5000);
}

Procesā piepirku klāt arī vienu mazu sensoru temperatūras un gaisa mitruma līmeņa mērīšanai. Interesants modulis, DHT22. Ja mērījumus veic nepārtaukti, notiek neliels, bet pastāvīgs elektrolīzes process. Lai to novērstu, ķēdē ievietoju tranzistoru un no atsevišķas datu izejas to ieslēdzu pirms datu ieguves tikai noteiktos intervālos.

Papildus labojums - ja seriālo portu never katru reizi ciet (Serial.end()), tad savienojums pēc kāda laika taimautojas un attiecīgi datus vairs nesūta.

Pirmie grafošanas mēģinājumi tika veikti uz rūtera, bet sarežģītākām kalkulācijām negribēju to pakļaut, tādēļ meklēju veidu kā datus sūtīt prom, glabāt internetā. Sākotnēji neizdevās atrast risinājumu, kurš ar visvienkāršāko GET pieprasījumu ļautu man tos saglabāt, tādēļ izveidoju savu, http://data.iists.it/ , kurš dara tieši to. Pāris dienas vēlāk, Gints bija atradis tādu cosm.com , kurš ļauj saglabāt datus un attēlo tos smukos grafikos. Nedaudz pa sarežģītu un datu iesūtīšana arī sarežģītāka kā es to gribētu. Tā nu uztaisīju ka tiek sūtīts uz abiem.

Novērojums tāds ka vēl aizvien sistēma mēdz nesūtīt, tas saistīts tieši ar rūteri, ar to ka tas ieslēgts Wifi klienta režīmā un mēdz nepieslēgties pa jaunu pie centrālā rūtera kad tas tiek pārstartēts vai kas tamlīdzīgs. Iespējams, jāievieš lokāls datu buferis rūterī, gadījumos kad nav interneta savienojuma. No tiem datiem kas ir arī šķiet, ka nepieciešama vēl viena pretestība, precīzāka intervāla attēlojumam.

Tālākie plāni ir ievērot konkrētus intervālus un kad mērījums sasniedz konkrētu robežu, ieslēgt notikumu, piemēram:

  • sūtīt e-pastu (aplaisti mani ;( )
  • ieslēgt mazu akvārija pumpi un pašam sevi apliet 

 

Sadaļa

Google+ ieraksti

Vairākkārt īdēju Feisbukā par nejēdzīgajiem ziņu izkārtojumiem un pretīgo profila izskatu. Sakarā ar to visu pārcēlos uz Google+, FB sūdam atstājot tikai ļoti pastarpinātu uzmanību.

Tā kā esmu pārāk laisks lai šeit drukātu savus ļoti svarīgos dzīves notikumus, nolēmu importēt savus Google+ ierakstus. Sacīts darīts, gan Google diezgan labi dalās ar datiem, gan arī Drupal prot ēst visu ko tam dod - pusstundas laikā sabakstīju risinājumu kas periodiski ielasa G+ publiskos ierakstus un importē šeit.

Pieļauju domu ka kāds no tiem būs anglisks vai bezsakarīgs, jo importēts tiek tikai teksts, bez pielikumiem (attēli, saites, raksti), bet šķiet ka būs labi tā pat ar.

Drupal izmantotie moduļi:
- Feeds
- Feeds JSONPath Parser
- Feeds Tamper

Google API:
- https://developers.google.com/+/api/

Papildinājums: Nepatīk man tie angliskie un bezsakarīgie ieraksti bez attēliem, pirmo lapu tomēr atgriezu iepriekšējā izskatā (vizuāli). Ieviesu skatu ar fitru, neattēlot G+ ierakstus, tie paliks zem atsevišķās sadaļas.

Sadaļa