Internet of Things(IoT)

The Internet of Things (IoT) is the interconnection of uniquely identifiable embedded computing devices within the existing Internet infrastructure. Typically, IoT is expected to offer advanced connectivity of devices, systems, and services that goes beyond machine-to-machine communications(M2M) and covers a variety of protocols, domains, and applications. The interconnection of these embedded devices is expected to usher in automation in nearly all fields.

The Internet of Things (IoT) is the network of physical objects accessed through the Internet as defined by technology analysts and visionaries. These objects contain embedded technology to interact with internal states or the external environment. In other words, when objects can sense and communicate, it changes how and where decisions are made, and who makes them. A common first step toward the IoT is converting networks on proprietary protocols to IP-based networks.



The IoT needs standard protocols. Popular Open source IoT protocols are CoAP, MQTT, ETSI SmartM2M or LwM2M. Two of the most promising for small devices are -
CoAP is designed for interoperability with the web. MQTT gives flexibility in communication patterns and acts purely as a pipe for binary data.
CoAP is the Constrained Application Protocol from the CoRE (Constrained Resource Environments) IETF group. Like HTTP, CoAP is a document transfer protocol. Unlike HTTP, CoAP is designed for the needs of constrained devices. CoAP packets are much smaller than HTTP TCP flows. Bitfields and mappings from strings to integers are used extensively to save space. Packets are simple to generate and can be parsed in place without consuming extra RAM in constrained devices.

CoAP runs over UDP not TCP. Clients and servers communicate through connectionless datagrams. Retries and reordering are implemented in the application stack. Removing the need for TCP may allow full IP networking in small microcontrollers. CoAP allows UDP broadcast and multicast to be used for addressing. CoAP follows a client/server model. Clients make requests to servers, servers send back responses. Clients may GET, PUT, POST and DELETE resources. CoAP is designed to interoperate with HTTP and the RESTful web at large through simple proxies. As CoAP is datagram based, it may be used on top of SMS and other packet based communications protocols. tinydtls is a library for Datagram Transport Layer Security (DTLS) covering both the client and the server state machine. It is implemented in C and provides support for the mandatory cipher suites specified in CoAP.

MQTT is a publish/subscribe messaging protocol designed for lightweight M2M communications. It was originally developed by IBM and is now an open standard. MQTT has a client/server model, where every sensor is a client and connects to a server, known as a broker over TCP. MQTT is message oriented. Every message is a discrete chunk of data, opaque to the broker. Every message is published to an address, known as a topic. Clients may subscribe to multiple topics. Every client subscribed to a topic receives every message published to the topic.

Popular Open Source IoT Operating Systems -
  • Contiki
  • TinyOS
  • RIOT
  • mbedOS
  • FreeRTOS
  • Google Brillo

ref:

Open Interconnect Consortium(OIC) - 
http://openinterconnect.org/

AllSeen Alliance - https://allseenalliance.org/

Qualcomm Allseen Alliance source code download - https://allseenalliance.org/developers/download

Intel iotivity source code download - https://www.iotivity.org/downloads


Google Thread IoT - http://www.threadgroup.org/

Industrial Internet Consortium - http://www.iiconsortium.org/

Google Nest and others group - http://www.threadgroup.org/

libcoap: CoAP implementation in C - http://sourceforge.net/projects/libcoap/



jCoAP: CoAP implementation in Java - https://code.google.com/p/jcoap/

CoAP.net: CoAP implementation in C# - http://sourceforge.net/projects/coapnet/

CoRE (Constrained Resource Environments) - https://datatracker.ietf.org/doc/charter-ietf-core/

Open IoT stack for Java - http://iot.eclipse.org/java/download/



Arduino Development

Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.

Arduino is a single-board microcontroller, intended to make building interactive objects or environments more accessible. The hardware consists of an open-source hardware board designed around an 8-bit Atmel AVR microcontroller, or a 32-bit Atmel ARM. Current models feature a USB interface, 6 analog input pins, as well as 14 digital I/O pins that accommodate various extension boards.


Arduino can sense the environment by receiving input from a variety of sensors and can affect its surroundings by controlling lights, motors, and other actuators. The microcontroller on the board is programmed using the Arduino programming language and the Arduino development environment. Arduino projects can be stand-alone or they can communicate with software on running on a computer (e.g. Flash, Processing, MaxMSP. The boards can be built by hand or purchased preassembled; the software can be downloaded for free. The hardware reference designs (CAD files) are available under an open-source license, you are free to adapt them to your needs.


avr-gcc, avr-g++, avr-objcopy, avrdude are the tools used in compiling 'C' code on arduino.


ref:


wiki - http://en.wikipedia.org/wiki/Arduino


Arduino website - http://www.arduino.cc/


Opensource Hardware Group(All about Arduino) - http://opensourcehardwaregroup.com/


Arduino IDE - http://arduino.cc/en/main/software


Arduino development environment - http://arduino.cc/en/guide/Environment


Arduino Development tools - http://playground.arduino.cc/Main/DevelopmentTools


Arduino library - https://github.com/arduino/Arduino/tree/master/hardware/arduino/cores/arduino


Arduino Makefile - https://github.com/sudar/Arduino-Makefile


Programming Arduino Uno in pure C/C++ - 

Arduino IDE for Microsoft Visual Studio and Atmel Studio - http://www.visualmicro.com/

Introduction to Arduino - http://www.instructables.com/id/Intro-to-Arduino/


Intel Arduino compatible Galileo board - http://www.intel.com/content/www/us/en/do-it-yourself/galileo-maker-quark-board.html


Arduiono IDE and sketch development overview - http://opensourcehardwaregroup.com/tutorial-3-arduino-ide-and-sketch-overview/


Arduino boards summary - http://www.hobbytronics.co.uk/arduino-summary


Advanced Arduino Hacking - https://pragprog.com/magazines/2011-04/advanced-arduino-hacking


Arduino Books(https://drive.google.com/folderview?id=0B5BO97vHUkN2VzEzTXFtRS1tSXc&usp=sharing_eid) -


Arduino Cookbooks -


Arduino Cookbook 2nd edition - 

Arduino Cookbook 1st edition - 

Functional Programming Overview

Functional programming is a style of programming which models computations as the evaluation of expressions. Functional Programming is when functions, not objects or procedures, are used as the fundamental building blocks of a program. Functions in this sense, not to be confused with 'C' language functions which are just procedures, are analogous to mathematical equations: they declare a relationship between two or more entitiesFunctional Programming, however, is not about mathematics but about abstraction and reducing complexity: as such, it provides a powerful paradigm in which to tackle complex, real-world programming tasks.

From pragmatic perspective, a beginner needs to understand only two concepts(Immutability and statelessness) in order to use it for everyday Functional Programming applications - 

First, data in functional programs should be immutable, which sounds serious but just means that it should never change. At first, this might seem odd (after all, who needs a program that never changes anything?), but in practice, you would simply create new data structures instead of modifying ones that already exist. For example, if you need to manipulate some data in an array, then you’d make a new array with the updated values, rather than revise the original array. Easy!

Secondly, functional programs should be stateless, which basically means they should perform every task as if for the first time, with no knowledge of what may or may not have happened earlier in the program’s execution. Combined with immutability, this helps us think of each function as if it were operating in a vacuum, blissfully ignorant of anything else in the application besides other functions. In more concrete terms, this means that your functions will operate only on data passed in as arguments and will never rely on outside values to perform their calculations.

The special characteristics and advantages of functional programming are often summed up more or less as follows. Functional programs contain no assignment statements, so variables, once given a value, never change. More generally, functional programs contain no side-effects at all. A function call can have no effect other than to compute its result. This eliminates a major source of bugs, and also makes the order of execution irrelevant — since no side effect can change an expression’s value, it can be evaluated at any time. This relieves the programmer of the burden of prescribing the flow of control. Since expressions can be evaluated at any time, one can freely replace variables by their values and vice versa - that is, programs are “referentially transparent”.

Prominent functional programming languages are Scheme, Haskell, OCaml, Erlang, Clojure, Racket, F#, Common Lisp, Scala ..

ref:

Functional Programming - http://en.wikipedia.org/wiki/Functional_programming

Introduction to Functional programming - http://www.smashingmagazine.com/2014/07/02/dont-be-scared-of-functional-programming/

Why Functional Programming matters - http://www.cse.chalmers.se/~rjmh/Papers/whyfp.pdf, http://worrydream.com/refs/Hughes-WhyFunctionalProgrammingMatters.pdf

Conception, Evolution, and Application of Functional Programming  Languages - http://www.utdallas.edu/~kXh060100/cs6301fa14/p359-hudak.pdf

Functional programming: A step backward - http://www.javaworld.com/article/2078610/java-concurrency/functional-programming--a-step-backward.html

erlang documentation - http://www.erlang.org/doc/pdf/otp-system-documentation.pdf

Haskell - http://www.haskell.org/haskellwiki/Haskell

Misc - 

Bluetooth Technology Overview

Bluetooth is a wireless technology for creating personal networks operating in the 2.4 GHz unlicensed band, with a range of 10 meters. Networks are usually formed ad-hoc from portable devices such as cellular phones, handhelds, and laptops. Unlike Wi-Fi wireless technology, Bluetooth offers higher level service profiles, such as FTP-like file servers, file pushing, voice transport, serial line emulation, and more. RFCOMM(Radio Frequency Communication) protocol provides emulation of serial ports over the L2CAP protocol. RFCOMM is a simple transport protocol, with additional provisions for emulating the 9 circuits of RS-232 (EIATIA-232-E) serial ports. It supports up to 60 simultaneous connections (RFCOMM channels) between two Bluetooth devices. RFCOMM is intended to cover applications that make use of the serial ports of the devices in which they reside. The communication segment is a direct connect Bluetooth link from one device to another.

Bluetooth Low Energy(BLE) or Bluetooth LE, marketed as Bluetooth Smart, is a wireless personal area network technology designed and marketed by the Bluetooth Special Interest Group. Compared to Classic Bluetooth, Bluetooth Smart is intended to provide considerably reduced power consumption and cost while maintaining a similar communication range. Bluetooth Smart uses the same 2.4 GHz radio frequencies as Classic Bluetooth, which allows dual-mode devices to share a single radio antenna. LE does, however, use a simpler modulation system. Bluetooth v4.0 standard is the creation of dual-mode capabilities that allow for classic Bluetooth operation as well as Bluetooth low energy support – the best of both worlds.  The latest Bluetooth specification uses a service-based architecture based on the attribute protocol (ATT). All communication in low energy takes place over the Generic Attribute Profile (GATT). An application or another profile uses the GATT profile so a client and server can interact in a structured way.The server contains a number of attributes, and the GATT Profile defines how to use the Attribute Protocol to discover, read, write and obtain indications. These features support a service-based architecture. The services are used as defined in the profile specifications. GATT enables you to expose service and characteristics defined in the profile specification.The GATT profile is also part of the core and defined in the core specification.

BlueZ: BlueZ is the Bluetooth stack for Linux kernel-based family of operating systems.

BlueZ BLE "C" API:
hci_le_set_scan_enable
hci_le_set_scan_parameters
hci_open_dev

BlueZ Bluetooth "C" API:
hci_inquiry
hci_open_dev

BLE "C" Programming Overview:


Call hci_le_set_scan_parameters to set options, setsockopt(SOL_HCI, HCI_FILTER, filter) to just get LE scan events and then callhci_le_set_scan_enable to turn on scanning(there's a function called hci_get_route to get an available device number). Each device connection was made with a socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP) which you then tell to connect to a particular device by calling connect on the socket with a struct sockaddr_l2 that has the particular device address in it.

ref:

Bluetooth SIG(Special Interest Group) - https://www.bluetooth.org/en-us




Linux Bluetooth library , BlueZ - http://www.bluez.org/

Introduction to Bluetooth programming - http://people.csail.mit.edu/albert/bluez-intro/


Bluetooth Specification RFCOMM with Application - http://hccc.ee.ccu.edu.tw/courses/bt/vg/rfcomm.pdf

Android Bluetooth overview - http://developer.android.com/guide/topics/connectivity/bluetooth.html

Android audio native programming using OpenSL ES - http://audioprograming.wordpress.com/2012/03/03/android-audio-streaming-with-opensl-es-and-the-ndk/


BlueNMEA is an Android application which sends location data over Bluetooth (RFCOMM) or TCP in the NMEA format - http://max.kellermann.name/projects/blue-nmea/