This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int getMacAddr(std::string ifname, char *macaddr) { | |
// need to open a socket to read the mac address | |
int sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); | |
if (sock == -1) { | |
auto err = std::string(strerror(errno)); | |
return Status::UnknownError("failed to open socket" + err); | |
} | |
struct ifreq ifr; | |
strcpy(ifr.ifr_name, ifname.c_str()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Workflow to build and deploy site to Github Pages using Hugo | |
# Name of Workflow | |
name: github pages | |
# Controls when the action will run. Triggers the workflow on push or pull request | |
# events but only for the master branch | |
on: | |
push: | |
branches: [ master ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"log" | |
) | |
type Configuration struct { | |
Broker string `json:"broker"` | |
Addr string `json:"Addr" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"os" | |
mqtt "github.com/eclipse/paho.mqtt.golang" | |
) | |
var ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Start Video opens the camera (sensor) and data (vidoe) starts streaming in. | |
// We will be streaming MJPEG for our initial use case. | |
func (vid *VideoPlayer) StartVideo() { | |
var err error | |
var buf []byte | |
l.Info("StartVideo Entered ... ") | |
defer l.Info("StartVideo Finished") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
def server(host, port): | |
sock = socket.socket() | |
sock.bind((host, port)) | |
sock.listen(2) | |
print(f'Server up and listening on {host} {port}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
class LED { | |
private: | |
gpio_num_t _pin = GPIO_NUM_0; | |
gpio_mode_t _mode = GPIO_MODE_OUTPUT; | |
int _state = 0; | |
public: | |
LED(gpio_num_t p); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==================================================================== | |
const int STACK_SIZE = 256; | |
const gpio_num_t LED_RED = GPIO_NUM_22; | |
const gpio_num_t LED_GREEN = GPIO_NUM_23; | |
// GLobal LEDs | |
// ==================================================================== | |
LED red = LED(LED_RED); | |
LED green = LED(LED_GREEN); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LED { | |
private: | |
gpio_num_t _pin = GPIO_NUM_0; | |
gpio_mode_t _mode = GPIO_MODE_OUTPUT; | |
int _state = 0; | |
public: | |
LED(gpio_num_t p); | |
void set(int val); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GetTimeStamp returns a timestamp in a file name friendly, version of the RFC3339 | |
// format. The string produced by RFC3339 includes a couple colons ':' that are not | |
// friendly to most filenames (unix and dos a like). The colons need to be escaped | |
// if used in a filename, since they are useless, we'll rip em. | |
func TimeStamp() string { | |
ts := time.Now().UTC().Format(time.RFC3339) | |
return strings.Replace(ts, ":", "", -1) // get rid of offensive colons | |
} |
NewerOlder