segunda-feira, 8 de junho de 2015

GSM bridge between two raspbx hosts

Disclaimer: I know there's a lot of options on the market for free long distance calls like Skype, Viber, WhatsApp and so on. The goal of this personal project was all along to come up with a proof of concept that actually works, study something different other than my actual job and, why not, have some fun :) BUT, yes, there's one single use case that this setup will be useful: You're in the middle of nowhere, no internet connection and you need to call someone in the other side of the planet but you don't want to pay a long distance call: BINGO!

Disclaimer2: For this tutorial you'll have to be prepared for Asterisk terminologies like trunks and channels. If you're not familiar with this vocabulary, please take a quick look at this documentation.

Description of the environment: The server1 is placed on the Brazilian side. It's a Raspberry Pi model B that runs an asterisk-modded-for-raspberry-pi distro called raspbx. Attached to it there's an USB GSM dongle with a SIM card for the local Brazilian operator. In the same network of my server1 there's a Cisco PAP2t Internet Phone Adapter and, attached to it, a regular land line telephone. The same setup is duplicated on the German side, except that the Raspberry Pi is model B+.

5VpNk+MmEP01rkouqZFky7PHzGZ2ctmqVPmwyRFLjESNJFQIf82v30ZqJNBHxh47yFXxxaIFNLzmPRrsRfA1P74IUqbfeUyzhf8QHxfBHwvf95bBF/hSllNjeVyvGkMiWIyVOsOGvVM0PqB1x2JaWRUl55lkpW2MeFHQSFo2IgQ/2NVeeWZ7LUmiPXaGTUSyofUHi2WKs/DDzv4nZUmqPXshTnhLordE8F2B/hZ+8Fp/mtc50X3hRI8PTXGJ7U9YXi+1p8Ia0TvnuWUQtGrRwz5fGQ4Ly1suYioak7ZlrHgzMQqeIZyCc2ipnvLjV5qpkOpoNc2+Tbxt4RK0sHxPNgiaFpU8achpDBHAIhcy5QkvSPbcWZ9qWKnqAUB6SmWewaMHj/TI5N/G8z+qym8rKFWSCPm7WhCq1z2BFo3tG4PxYIsi7tUAi/E+2ol97VUVmmGrsU7OHE0V34kIa+FswXFCsVbNBwTnhfKcSnGqw5kRyfZ27wQjlbT1OmjhAdEdRxpdw8R22KkgVbmlonZXsoUfZjCkp5jt4TFRjyOmXyoKIAjvV/0O3I606Ft7IT6kTNJNSWpYDqAcdhhxpFRIqoVkAt0hbthAywzKTvCA5YNBYmRAavBX264BGglrAL2rtmB42XxXQsiLBGAYQTYH8cyngZ0bQt8bQrgegfDLDSDUri5SBYueM0nE51QBZ2uqQr2/OFAFdG2qAt9J2CTcr7c26pqzK3ecxe3cgIEVgEIB4XAPRLB6tIEIh0B4ev82kQhvQT29Pm+zIX/Al3M49zlOrYecqlF1wCkPdwCn6gVYiJN6pVrUhXtQtpEouMp30LVB6ZKU9VGBVREfrnLnG+rSYU6CgmKAIWlGy5QXdA4k9JQQidWZqYW2XYOEXhf/ITlrBt5JauGNMNCrj5guhHDIwSvOHP69nzlCvT5nOHR4Q4ZfcOqYhtY9iD1tcHns8PHuxak2tBt3IwJ3snE3GjHPmUT7vodDySqY71CiU/y7T8XNhaMM/YWj754uSJX0/a/OlR4R9qvwRI38n2z9Y5FwtvVr5xPpN76ddXt2mX+P3L62Cfg8WNiy5jIDD7APA4utIO8sY/ATh05Y4OblwMXbkLBZBj/9KGI60H57veh18NEtzC3WS4CDNTAaQtGpRpSRqmKRjYClPF2Nz16vDGEygNBQmTho29nagh7+4nD31kXB620F7baou2g0D1uZPzV90JHXvy5rhHLQUR2rdtrnhW+ofgkVuVrfIcnVSi22lfqqF/sgKW8X/1k5uUtKhD1OaBlxwomhht4fJybyF28kbfw3zpxPj76n9rx0KT0mh3w1PaDY/aDcVO/+LBA8/wQ=
What it does: This is the list of features that this project performs right now:
  1. Someone in Brazil calls my Brazilian number, the dongle1 answers the call, redirects to an IAX2 trunk directly to server2. The server2 takes this incoming call and uses the dongle2 to place a new call to my german cellphone. The other way is still pinned to a single phone -- like, call my dongle2 to reach a single number in Brazilian side -- but improvements are coming.
  2. Someone uses phone1 on Brazilian side to call extension phone2 on German side (and vice-versa) like a regular landline phone.
  3. Someone uses phone1 or phone2 to reach my german cellphone.

Ok, so LET'S DO IT!!

I'm gonna skip the PAP2t configuration because I think it's too much. This is only needed if you want to use land line telephones, it's not required for the GSM bridge. If anyone is interested in doing that, please leave a comment and I'll write a new post only for that configuration.

Important note: All the configuration explained from now on is identical on both servers.
  1. Install raspbx on your RPi's SD card. Also take a time to read through the raspbx documentation, which is very useful
  2. Use the script install-dongle (built-in inside raspbx) to install your dongle on your RPi. Important notes regarding problems I got:
    1. There's a list of GSM dongles that are tested with voice, SMS and USSD. I bought the Huawei E160;
    2. I had to unlock the voice feature with DC-Unlocker for Windows;
    3. Plug your dongle and only after that plug your RPi power. If you try to plug your dongle while the RPi turned on, you may experience your RPi to reboot due to power consumption failures;
    4. If your RPi starts rebooting it's because it can't handle the gsm dongle power consumption, in this case, use a proper powered USB hub. I bought the D-Link Dub-H7
    5. Find out the IMEI and the IMSI code of your dongle and set the correct values under /etc/asterisk/dongle.conf because /dev/ttyUSB1 or /dev/ttyUSB2 may change;
  3. Before you start configuring raspbx itself, it's important that you have both sides with network configured properly with static IPs and (in my case) DynDNS. I didn't want to open too many ports on the routers on both sides so I just setup an OpenVPN vpn; 
  4. Setup a new custom trunk for your dongle under Connectivity  Trunks  Add Custom Trunk and set these values:

    Trunk Name: to-my-cellphone
    Outbound CallerID: Your SIM card number with country code (with a plus sign at the beginning)
    Custom Dial String: dongle/dongle0/$OUTNUM$

    Note: This is the trunk that will actually place the inbound calls to your personal telephone.

  5. Setup a new IAX2 trunk under Connectivity  Trunks  Add IAX2 Trunk and set these values:

    General Settings:
    Trunk Name: Something that would remember the incoming connection from the other server
    Outbound CallerID: Your personal phone number

    Outgoing Settings:
    Trunk Name: (same as above, I also used the same name and it's ok)

    host=static IP under vpn of the remote server
    username=any username
    secret=any password
    type=friend
    trunk=yes
    qualify=yes
    qualifyfreqok=25000
    tos=0x18

    Note: The IAX2 trunk is responsible for redirecting calls from this server to the other.

  6. Setup a new inbound route under Connectivity  Inbound Routes → Add Incoming Route:

    DID Number: Your SIM card number with country code (with a plus sign at the beginning)
    CallerID Number: Your personal cell phone number
    Set Destinations: Trunk and your recently created IAX2 trunk.

    Note: This is the route responsible to redirect an inbound call on your local dongle over the IAX2 trunk and then to your remote server.
If you noticed any omitted fields in the above configurations, it's because I didn't fill with anything or it's not important. I also did some extra work on Claning the SIM card memory for SMS every once in a while, I set a static IP for the OpenVPN so each server can always see each other, an additional service to check my credit balance every month and so and so forth. If you also want details like that please let me know in the comments :-) 

That's it! You did it! If you need more help setting up anything else please let me know in the comments of this post. Good luck and have fun! :-)

quinta-feira, 9 de janeiro de 2014

Vendo: Placa Beagleboard rev C4 + Placa de expansão BeagleBuddy Zippy

tl;dr: R$200,00 por fora do Mercado Livre. Interessados deixem contato nos comentários.

Pessoal, estou vendendo esta placa de desenvolvimento apenas por que os repositórios de software que costumava usar foram descontinuados para este modelo (parou no Ubuntu Server 12.03, ainda da pra instalar e atualizar os pacotes, mas não tem versões mais novas). Apesar disso, é uma placa de baixíssimo consumo de energia, ideal para desenvolvimento de aplicações embarcadas e testes com processadores ARM.







Como mostram as fotos, a BeagleBoard já está soldada à placa de expansão BeagleBuddy Zippy e ambas estão muito bem cuidadas e funcionando normalmente. Já acompanha a bateria de 3V para o RealTime Clock.

Junto com as paquinhas vão:

  • Caixa original
  • Fonte de alimentação de 5V
  • Case de acrílico + um case fosco (na época que eu comprei veio um de brinde que eu nunca usei)
  • Cabo USB-serial
  • Bateria 3V para o RealTime Clock

Tudo isso por apenas R$200,00!

(tenho conta no ITAU, aceito PayPal e Bitcoin)

Interessados: Deixem o contato nos comentários.


BeagleBoard rev C4:
  • Package on Package POP CPU/Memory chip.
    • Processor TI OMAP3530 Processor - 720 MHz ARM Cortex-A8 core
    • 'HD capable' TMS320C64x+ core (520 MHz up to 720p @30 fps)
    • Imagination Technologies PowerVR SGX 2D/3D graphics processor supporting dual independent displays
    • 256 MB LPDDR RAM
    • 256 MB NAND Flash memory
  • Peripheral connections
    • DVI-D (HDMI connector chosen for size - maximum resolution is 1280×1024)
    • S-Video
    • USB OTG (mini AB)
    • 1 USB port
    • SD/MMC card slot
    • Stereo in and out jacks
    • RS-232 port
    • JTAG connector
    • Power socket (5 V barrel connector type)
    • Development
      • Boot code stored in ROM
      • Boot from NAND memory, SD/MMC, USB, or serial
      • Alternative boot source button.

BeagleBuddy Zippy:
  • 10BaseT Ethernet 
  • Additional SD/MMC interface 
  • Battery backed-up Real Time Clock (RTC)
  • Additional RS-232 serial port
  • 5V I2C expansion interface.

sábado, 13 de julho de 2013

Entendendo a digestão de um bebê.

Este post vai ser menos poético e mais técnico que o outro. Se não te interessa saber sobre refluxo e como evitá-lo, pode voltar a ler o seu jornal.

Pois bem, Carolina estava tendo bastante problema de refluxo, Marcelle vasculhou os confins da deep-web e encontrou o recomendado Dr David Costa, osteopata - Ele atende na academia Companhia Atletica, perto da Avenida dos Bandeirantes em São Paulo. Ele apelou pra tudo o que eu acredito nessa vida, a ciência. Explicou com detalhes de anatomia e química do por que a Carol ter refluxo e por que as vezes isso é normal. Neste post vou tentar entregar um pouco do seu ouro. Mas de qualquer forma, recomendo muito a consulta, médico atencioso, paciente e ouve os pais com seus problemas.

Antes de tudo um aviso importante: EU NÃO SOU UM PROFISSIONAL DA SAÚDE. Use este post como uma orientação e se tiver problemas procure um médico.

1) Meu filho mama muito bem no peito esquerdo, relaxa e até dorme; mas no peito direito ela fica inquieto e irritado. Por que isso acontece?
Pelo desenho do aparelho digestivo acima, nota-se que a saída do estômago é uma caída suave para a esquerda. Ora, se o bebê se inclina para a esquerda (fazendo o contato barriga-com-barriga que as mamães já estão por dentro) para mamar, o estômago é mais facilmente esvaziado, dando uma sensação de alívio ao bebê. O contrário também é válido, se ele se inclinar para o lado direito, o leite vai se acumulando do lado direito do estômago, ele logo fica empapuçado e fica com sentimentos misturados: Ainda tenho fome, mas algo me incomoda = choro. Então a dica aqui é: comece pelo peito direito, quando empapuçar, mande para o esquerdo e deixe ele relaxar.

2) Meu filho regurgita SEMPRE depois de mamar. O que faço?


Isso é normal. Existe um músculo circular em formal de anel que separa o estômago do esôfago chamado de Cárdia. Este músculo não é forte e nem possui reflexo para fechar ou abrir direito em bebês. Isso significa que, com o estômago cheio de leite - as vezes cheio demais - é natural que alguma coisa saia. Mas atenção, esse refluxo é de cor branca e fluida, assim como o leite. Caso seja em formato de queijo, veja o item 3.

3) Quando meu bebê regurgita, sai um queijo e ele fica muito irritado e chora muito. O que faço? 

Isso tem a ver com o a fermentação do leite no estômago. Leite fermentado nada mais é do que queijo, se ele regurgitar queijo, quer dizer que o tempo entre as mamadas está errado. Ele fica irritado por que o PH dessa solução que fica no estômago é ácido, é só lembrar daquele seu porre que você vomitou até ficar com a garganta ardendo, bem era por causa disso.

Então, quando ele começar a mamar, ligue o cronômetro e não deixe passar de 30 minutos. Depois de 30 minutos, o estômago já começa a digerir o leite e este começa a virar queijo. Qualquer estímulo na cárdia pode fazer ele regurgitar e isso vai irritá-lo bastante. Depois disso tente respeitar o período mínimo de 2 horas para concluir a digestão antes de dar mais comida.

Embora bastante explicativas, essas dicas obviamente não são tudo. As vezes, ele vai acordar no meio da noite com dor de barriga, as vezes não vai querer dormir. Nessas ocasiões, boa sorte.

sexta-feira, 5 de julho de 2013

Junto com a filha, nasce um pai


Este post começou com o pedido de uma amigo velho para compartilhar as experiências vividas nessas poucas semanas de pai. Comecei a escrever o email e fui achando que poderia virar um post. Pois bem, ca estamos.

Já no sétimo mês fizemos um curso para gestantes. Aprendemos a dar banho, a trocar fralda e tudo mais. Mas obviamente que nem tudo estava previsto no manual. Então aqui deixo algumas das poucas experiências que já passei. Mais informações vocês podem encontrar no blog da Marcelle.

Antes do nascimento, converse com sua filha: Pode parecer bobagem, mas conversar com a barriga da sua esposa é bastante importante. Depois do oitavo mês de gestação, o aparelho auditivo já está formado e ela já vai começar a reconhecer a sua voz. O dia do parto vai ser a pior experiência da vida dela, vai sair daquele quentinho e escurinho pra ir pra um ambiente claro e gelado na mão de um monte de gente estranha. Ter uma voz familiar como referência é o diferencial para ela manter a calma e não deixar a experiência tão traumatizante assim.

Depois do nascimento, converse com a sua filha também: Sempre que for trocar a fralda, dar banho ou botar pra dormir, converse com sua filha. "Filha, vou trocar sua fralda, ela não pode ficar suja. Vou tirar seu casaquinho agora..." E lembre-se: SEM BABY TALK. Voz normal, ela tem que reconhecer a sua voz. Claro que eles ainda não entendem, mas ouvir a voz do pai ou da mãe é algo mágico que acalma.

Depois de adulta, continue conversando. Mas isso a gente já sabe. :)

Rotina é MUITO importante: Bebês não sabem o que é dia e nem o que é noite, tenha uma rotina clara. De dia abra as janelas, faça barulho e acorde o bebê a cada duas horas para mamar. Se não acordar só com estímulos, tire a roupa, eles sempre acordam assim. A noite, diminua o ritmo, abaixe o volume das coisas e não deixe tantas luzes acesas. Ensine que é hora de dormir. Dê banho sempre no mesmo horário, arrote e bote no berço. É uma receita quase infalível.

Parece que no começo você vai morrer, que não vai dormir nunca mais, que ela acorda a noite inteira e acabou tudo. SIM. Mas passa. E não demora. A Carol já está acordando apenas UMA vez por noite.

Bebês choram por motivos simples de desconforto: Ou é fome, ou está com fralda suja ou está com calor ou com frio. Se você verificar todos esses fatores e estiver tudo OK, então é hora de levar ao hospital. Bebês recém nascidos não são manhosos, nem mal acostumados nem malandros - eles ainda não aprenderam o que é isso. Se chorar é por que tem algo de errado mesmo.

Na hora de dormir: Não deixe dormir no colo pra depois colocar no berço, é importante que ela aprenda a dormir sozinha e no berço. Do contrário sim, você vai estar mal acostumando sua filha.

E o que eu descobri sendo pai? Bem, aprenda a se respeitar também. Você não vai nascer pai, vai aprender. Errar não vai o tornar a pior pessoa do universo, com calma a gente chega lá :)

Bibliografia recomendada:
Os Bebês e suas mães - D. W. Winnicott.
A encantadora de bebês - Tracy Hogg.

quinta-feira, 20 de dezembro de 2012

Amigo Blogueiro 2012

Confesso que não sei o que escrever pro meu amigo secreto, nem o conhecia antes do evento e tive que pesquisar MUITO (cof cof), olhar no google pra poder escrever algo legal sobre ele. 

Poise bem! Ele comanda o blog  Franquias Baratas de Sucesso e da dicas bastante espertas para quem quer abrir uma franquia, começar um trampo novo e quem sabe até uma vida nova. Posts ágeis direto ao ponto sem rodeios. Já aproveitei pra me antenar e entender melhor o conceito correto do termo franquia, anotei também as 10 Franquias Baratas de se investir. Ótimas dicas.

Mas chega de business, direto do Instagram dele tem várias fotos belas de por do sol direto de Belo Horizonte, que é a cidade onde mora. E na mesma página onde tem as lindas paisagens mineiras, tem também os gadgets todos desmontados (opa, cheguei na minha praia). Ah eu queria ter a coragem desse rapaz pra abrir e ver a anatomia dos meus devices de perto :-)

#Samsung #Galaxy #SII

Keep focused! Galaxy SII disassembly.

Amigo secreto, Luiz Gadetto, prazer conhecê-lo. Vou seguir pra saber mais das experiências com os devices :-) Feliz natal e ótimo ano 2013 (se existir) Grande abraço!

sexta-feira, 13 de julho de 2012

Vendo Canon XS e Lente SIGMA 19-200mm

Vendinha do Otubo aberta novamente!

Algum de vocês deve ter visto meu problema com algumas fraudes no Mercado Livre e ainda um caloteiro que comprou e não pagou. Decidi então tentar vender meu equipamento de fotografia por aqui também. Os preços não são fixos mas sempre podemos negociar, aceitamos qualquer negócio. Então vamos lá:
  • 1 lente 18-200mm SIGMA + parasol
  • Preço: R$600,00







quinta-feira, 23 de fevereiro de 2012

Flexget & Transmission Daemon downloading your torrents for you

  • Do you watch dozens of TV shows and it sucks to download every single one of them?
  • Do you have trouble on finding torrent files?
  • Is it hard to keep track which one has new episodes or not?



Well, your problems are finally over! By the end of this (pretty cool) straight-forward tutorial you'll have an email at your inbox every time there's a new episode to watch. And there's more! Call now and.. Ok, I got it.

Note: I configured this service on my home-based Ubuntu Server running on a Beagle Board - no arch dependent. In other words, if you want a fully automatic service, you might want to install it on a always-on-computer, not your notebook. :)

Ok, cut the crap. Let's do this!

1) Download and install Flexget. Keep cool, it's easy.
2) Before configuring flexget, install transmission-daemon:

    root@minivader ~ # sudo apt-get install transmission-daemon

and edit the configuration file to look like this: (customize the configuration as you wish and erase the comments in red)

root@minivader ~ # cat /etc/transmission-daemon/settings.json 
{
    "alt-speed-down": 50, 
    "alt-speed-enabled": false, 
    "alt-speed-time-begin": 540, 
    "alt-speed-time-day": 127, 
    "alt-speed-time-enabled": false, 
    "alt-speed-time-end": 1020, 
    "alt-speed-up": 50, 
    "bind-address-ipv4": "0.0.0.0", 
    "bind-address-ipv6": "::", 
    "blocklist-enabled": false, 
    "blocklist-url": "http://www.example.com/blocklist", 
    "cache-size-mb": 4, 
    "dht-enabled": true, 
    "download-dir": "/media/deathstar/torrent", 
      change this to your destination folder
    "download-limit": 100, 
    "download-limit-enabled": 0, 
    "encryption": 1, 
    "idle-seeding-limit": 30, 
    "idle-seeding-limit-enabled": false, 
    "incomplete-dir": "/home/otubo/Downloads", 
    "incomplete-dir-enabled": false, 
    "lpd-enabled": false, 
    "max-peers-global": 200, 
    "message-level": 2, 
    "peer-congestion-algorithm": "", 
    "peer-limit-global": 10000, 
    "peer-limit-per-torrent": 1000, 
    "peer-port": 51413, 
    "peer-port-random-high": 65535, 
    "peer-port-random-low": 49152, 
    "peer-port-random-on-start": false, 
    "peer-socket-tos": "default", 
    "pex-enabled": true, 
    "port-forwarding-enabled": false, 
    "preallocation": 1, 
    "prefetch-enabled": 1, 
    "ratio-limit": 2, 
    "ratio-limit-enabled": false, 
    "rename-partial-files": true, 
    "rpc-authentication-required": true, 
    "rpc-bind-address": "0.0.0.0", 
    "rpc-enabled": true, 
    "rpc-password": "whatever", 
    "rpc-port": 9091, 
    "rpc-url": "/transmission/", 
    "rpc-username": "otubo", 
    "rpc-whitelist": "*", 
    "rpc-whitelist-enabled": true,
     enable all the rpc options above (user & password optional) this is important to make flexget talk to transmission AND access transmission daemon web @ http://localhost:9091
    "script-torrent-done-enabled": false, 
    "script-torrent-done-filename": "", 
    "speed-limit-down": 100, 
    "speed-limit-down-enabled": false, 
    "speed-limit-up": 100, 
    "speed-limit-up-enabled": false, 
    "start-added-torrents": true, 
    "trash-original-torrent-files": false, 
    "umask": 18, 
    "upload-limit": 100, 
    "upload-limit-enabled": 0, 
    "upload-slots-per-torrent": 14, 
    "utp-enabled": true
}

Note: Remember NOT to kill transmission-daemon, you need to SIGHUP it in order to reload the configuration. You can either:

    kill -HUP pid

or

    invoke-rc.d transmission-daemon reload

3) Now configure Flexget to look like this: (customize the configuration as you wish and erase the comments in red)

root@minivader ~ # cat ~/.flexget/config.yml 
presets:
  global:
    transmission:
      host: localhost
      port: 9091
      username: otubo
      password: whatever
    email:
      change your gmail credentials
      from: youremail@gmail.com
      to:
        - youremail@gmail.com
        - your_room_mate@gmail.com
      smtp_host: smtp.gmail.com
      smtp_port: 587
      smtp_username: youremail
      smtp_password: yourpasswd
      smtp_tls: yes
    series:
      configure as you wish, plain text, human readable :)
      - The Big Bang Theory
      - House
      - Family Guy
      - How I Met Your Mother
      - The New Girl
      - Grey's Anatomy
      - Private Practice
      - The Secret Circle
      - The Vampire Diaries
      - Hart of Dixie
      - The Walking Dead
      - The Good Wife
      - Switched at birth
      - Once Upon a Time
      - True Blood
      - Teen Wolf

feeds:
  this is where I look for new torrents, you can add yours
  btchat-vtv:
    rss: http://rss.bt-chat.com/?group=2
  btchat-eztv:
    rss: http://rss.bt-chat.com/?group=3
  btchat:
    rss: http://rss.bt-chat.com/?group=1
  btchat-verified:
    rss: http://rss.bt-chat.com/?group=230
  ezrss-latest:
    rss: http://www.ezrss.it/feed/

4) Now put your flexget into a cronjob:

    root@minivader ~ # crontab -l|grep flexget
    @hourly /usr/local/bin/flexget --cron

Now you might want to run:

    root@minivader ~ # flexget -v

and check if everything goes fine. Once everything goes smoothly, DONE! Now you can LITERALLY sit and watch your server download all the content for you :-)

How it works, for those who like to read the post until the end: cron will run flexget hourly. It will read the RSS from the feed you pointed trying to match the TV Show name. If it matches, flexget will send you an email AND perform an RPC to talk to transmission in order to add the torrent file in the queue for download. You can check the progress in the transmission daemon web @ http://localhost:9091

5) Missing points that I leave for you to have some fun:
  • We should tell transmission-daemon to stop seeding at some point (after it finishes, or after it gets to a certain ratio number would be perfect)
  • It would be really cool to download each TV show into a separate directory.
  • AND EVEN COOLER if we could separate the files into Season folders, creating new ones when season changes.
All right, that's it. have fun :)