Skip to content

Instantly share code, notes, and snippets.

View chiragtoor's full-sized avatar

Chirag Singh Toor chiragtoor

View GitHub Profile
# in the initialization we let ErlPort know where our python code
# is as well as the python version
{:ok, python} = :python.start([{:python_path,
to_char_list(Path.expand("python"))}, {:python, 'python'}])
commercial_zones = get_commercial_zones()
|> Enum.map(fn(%{"geometry" => %{"coordinates" => [coordinates]}}) ->
coordinates
end)
namespace py geo
struct Point {
1: double lat,
2: double lng
}
struct Boundary {
2: list<Point> points
}
service GeoService {
bool blockInZone(1:Boundary block, 2:Boundary zone)
import glob
import sys
sys.path.append('gen-py')
from geo import GeoService
from geo.ttypes import Point, Boundary
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from thrift.server import TServer
from shapely.geometry import Polygon
defmodule PythonCalls.Client do
use Riffed.Client,
structs: PythonCalls.Models,
client_opts: [
host: "localhost",
port: 9090,
retries: 3,
framed: true
],
service: :geo_service_thrift,
def thrift do
# start the client to connect with the thrift service
PythonCalls.Client.start_link
# convert the zones to Boundary structs defined in the geoservice.thrift file
commercial_zones = get_commercial_zones()
|> Enum.map(fn(%{"geometry" => %{"coordinates" => [coordinates]}}) ->
PythonCalls.Models.Boundary.new(points: getPointsFromCoordinates(coordinates))
end)
commercial_blocks = get_blocks()
AT+SAPBR=3,1,"CONTYPE","GPRS"
AT+SAPBR=3,1,"APN","hologram"
AT+SAPBR=1,1
AT+HTTPINIT"
AT+HTTPSSL=1"
AT+HTTPPARA="URL","https://ae076e05.ngrok.io/api/test"
AT+HTTPPARA="CID",1"
AT+HTTPPARA="USERDATA","Authorization: bearer [AUTH_TOKEN]"
AT+HTTPPARA="CONTENT","application/json"
AT+HTTPSCONT
config :nerves_init_gadget,
# 'eth0' sets up the ethernet connection
ifname: "eth0",
address_method: :dhcpd,
mdns_domain: "nerves.local",
node_name: "cellular",
node_host: :mdns_domain,
ssh_console_port: 22
CONFIG_MKNOD=y
CONFIG_WC=y
CONFIG_USB_SERIAL_OPTION=m
CONFIG_PPP=m
CONFIG_PPP_BSDCOMP=m
CONFIG_PPP_DEFLATE=m
CONFIG_PPP_FILTER=y
CONFIG_PPP_MPPE=m
CONFIG_PPP_MULTILINK=y
CONFIG_PPP_ASYNC=m
CONFIG_PPP_SYNC_TTY=m
BR2_PACKAGE_PPPD=y
BR2_PACKAGE_BUSYBOX_CONFIG_FRAGMENT_FILES="${NERVES_DEFCONFIG_DIR}/busybox.fragment"