LoRa & LoRaWAN nedir?

Long Range Wide Area kısaltmasından oluşan LoRa, kendine özgü bir modülasyon tekniğiyle uzak mesafelere paket gönderebilen L1 (fiziksel katman) protokolüdür.

Lora Alliance, LoRa’ya Mac fonksiyonu kazandırarak LoRaWAN adı altında standartlaştırma çalışmalarını yürütmektedir. LoRaWAN bir  LPWAN (Low Power Wide Area Network) teknolojisi olup,  pil ömrünün ve iletişim mesafesinin önemli ve ön planda olduğu IoT (Internet of  Things) için olmaz olmaz bir iletişim atl yapısı sunmaktadır.

screen-shot-2016-10-14-at-15-12-33

Ülkemizde 868 Mhz ISM bandında kullanılabilen LoRaWAN,  açık alanda 15 km, kapalı alanlarda 3 km’ye kadar paket iletim mesafesi sunmaktadır.

Henüz çok yeni bir teknoloji olmakla birlikte bir çok ülkede hızla yayılmakta ve Avrupada bir çok şehir LoRaWAN ile tamamen kapsama alanı altına alınmaya başlanmıştır. Türkiye sadece skysens bu alanda hizmet vermektedir,  sayılarının artması umuyoruz.

LoRaWAN hakkında bilinirliği artırmak ve bu teknoloji meraklarını bir araya getirmek amacıyla Türkiye LoRaWAN topluluğunu kurduk ve geçtiğimiz Eylül ayında ilk etkinliğimizi gerçekleştirdik. “LoRaWAN ile IoT Projeleri/IoT Projects with LoRaWAN” temalı ikinci etkinliğimiz için hazırlıkları neredeyse tamamladık, konuya meraklı olan veya iş proje/iş olanakları arayan herkesi bekliyoruz.


Go Language on OpenWRT – Carambola2

I’m playing with interesting go language which is built for system programming however, golang has been using to solve variety problems. For me, the most important aspect of the language is it is compiled and cross platform . Its simple, easy to learn and solves resource problems efficiently.

For test purposes, I wrote a simple hello world application, which dumps  struct as hex string on Carambola2 (MIP32 arch.). To be able compile go source code on OpenWRT gccgo is required. There are OpenWRT repos adds go lang support to gcc for MIPS32 architecture.

If target environment doesn’t contain go library (libgo.so) , source code should be compiled with “-static-libgo” flag. In my case;

mips-openwrt-linux-gccgo -g -static-libgo hello.go -o hello2

Output ;

root@Carambola2:~# ls -lah
drwxr-xr-x 1 root root 0 Aug 18 18:09 .
drwxr-xr-x 1 root root 0 Aug 18 17:58 ..
-rwxr-xr-x 1 root root 16.5K Aug 18 2016 hello
-rwxr-xr-x 1 root root 2.8M Aug 18 18:09 hello2
root@Carambola2:~# ./hello2
00000000 01 02 |..|

root@Carambola2:~#

Script;

package main

import (
       "fmt"
       "bytes"
       "encoding/binary"
       "encoding/hex"
)

type Data struct {
       X uint8
       y uint8
}

func main() {
       var buf bytes.Buffer
       dt := Data{1, 2}

       binary.Write(&buf, binary.BigEndian, dt)
       fmt.Println(hex.Dump(buf.Bytes()))
}

 

Also see this blog post further information.

 


OpenWRT Mac OSX SDK & Toolchain

OpenWRT (trunk version for x86) and Carambola2 (v2.8) SDK and Toolchain development binaries can be found at http://mehmetalierturk.com/openwrt for Mac OSX (El Capitan). Binaries contain main developments packages  as preinstalled (gcc & gdb) and others packed under packages subdir.


My OpenWRT Development Environment on OSX with Vagrant

You can find how to build OpenWRT on Mac OSX from my previous posts, here I’ll share my development environment for wireless devices.

IDE:  After XCode, Clion is the best IDE for C/C++ development on OS X.  Only disadvantage is, it doesn’t support remote debugging.

Toolchain: Cross compiled toolchain for openWRT

Vagrant: There are boxes for openwrt I use qqshfox/openwrt-barrier_breaker and I added a shutdown script to get it working correctly. Auto sync doesn’t work instead installed both Mac and OpenWRT rsync to handle configuration.

I use Clion for development, and vagran rsync-auto sync’s binaries with vagrant box. Also, I  use USB Wifi adapter on vagrant box ( TP-Link WN727N works perfect).

My CMakeList.txt files is as follows;


cmake_minimum_required(VERSION 3.5)
project(CNetLink)

#set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -std=c++11”)
set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -Wall -Werror”)

set(SOURCE_FILES main.c CNetLib.c CNetLib.h)
add_executable(CNetLink ${SOURCE_FILES})

set(CMAKE_SYSTEM_NAME Linux)

SET(CMAKE_STAGING_PREFIX /Volumes/OpenWRT/openwrt/staging_dir)
SET(STAGING_DIR /Volumes/OpenWRT/openwrt/staging_dir)
INCLUDE_DIRECTORIES(${STAGING_DIR}/target-i386_i486_uClibc-0.9.33.2/usr/include/libnl3/)
LINK_DIRECTORIES(${STAGING_DIR}/target-i386_i486_uClibc-0.9.33.2/usr/lib/)

set(TOOLCHAIN_DIR ${STAGING_DIR}/toolchain-i386_i486_gcc-4.8-linaro_uClibc-0.9.33.2)

SET(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}/bin/i486-openwrt-linux-uclibc-gcc)
SET(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}/bin/i486-openwrt-linux-uclibc-g++)
SET(CMAKE_STRIP ${TOOLCHAIN_DIR}/bin/i486-openwrt-linux-uclibc-strip)
SET(CMAKE_FIND_ROOT_PATH ${STAGING_DIR})

set(CMAKE_C_FLAGS “${CMAKE_C_FLAGS} -Wall -Werror -L ${STAGING_DIR}/target-i386_i486_uClibc-0.9.33.2/usr/lib/ -lnl-genl-3 -lnl-3”)

SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)


OpenWRT 15.05 Chaos Calmer on Mac OS X El Capitan 10.11

When I try to build new OpenWRT release 15.05 Chaos Calmer on OSX 10.11 mkimage build fails with following error:
Undefined symbols for architecture x86_64:
“_ERR_remove_thread_state”, referenced from:
_rsa_sign in rsa-sign.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[5]: *** [tools/dumpimage] Error 1
make[4]: *** [tools-only] Error 2
make[3]: *** [/Volumes/OpenWRT/openwrt/build_dir/host/u-boot-2014.10/.built] Error 2
make[3]: Leaving directory `/Volumes/OpenWRT/openwrt/tools/mkimage’
make[2]: *** [tools/mkimage/compile] Error 2
make[2]: Leaving directory `/Volumes/OpenWRT/openwrt’
make[1]: *** [/Volumes/OpenWRT/openwrt/staging_dir/target-mips_34kc_uClibc-0.9.33.2/stamp/.tools_install_yynyynynynyyyyyyyyyyyyyyyyyyynyyyyynnyyynyyynnnyy] Error 2
make[1]: Leaving directory `/Volumes/OpenWRT/openwrt’
make: *** [world] Error 2

So, I replaced openssl with the one comes with homebrew build. Replaced Host/Compile section in tools/mkimage/Makefile, solves the issue.

define Host/Compile

$(MAKE) -C $(HOST_BUILD_DIR) defconfig

HOSTCFLAGS=”$(HOST_CFLAGS) -I/usr/local/Cellar/openssl/1.0.2d_1/include” \
HOSTLDFLAGS=”$(HOST_STATIC_LINKING) $(HOST_LDFLAGS) -L/usr/local/Cellar/openssl/1.0.2d_1/lib” \
$(MAKE) -C $(HOST_BUILD_DIR) tools-only
endef