Skip to content

Instantly share code, notes, and snippets.

View funvill's full-sized avatar

Steven Smethurst funvill

View GitHub Profile
@funvill
funvill / blink.cpp
Created February 22, 2018 20:02
Blink Arduino sketch
bool CallbackGetPropertyUInt( UINT object_type, UINT object_instance, UINT property_identifer, UINT device_identifier, UINT * value ) {
const unsigned int PROPERTY_IDENTIFERS_DATABASE_REVISION = 155;
if (object_type == OBJECT_TYPE_DEVICE) {
if (property_identifer == PROPERTY_IDENTIFERS_DATABASE_REVISION) {
// database_revision = 155,
*value = 199;
return true;
}
}
return false;
// To be a good BACnet Server we should annouce ourself when joining a network.
// Generate the IAM message and send it.
char packet[MAXIMUM_BACNET_MESSAGE];
unsigned short payloadSize = fpIAm(SETTING_SERVER_BACNET_NETWORK, deviceOffset, packet, MAXIMUM_BACNET_MESSAGE, deviceOffset);
if (payloadSize > 0) {
// Generate the connection string.
BYTE connectionString[10];
sscanf_s(SETTING_CLIENT_IP_ADDRESS, "255.255.255.255");
connectionString[4] = SETTING_BACNET_UDP_PORT / 256;

Principles of Adult Behavior

  1. Be patient. No matter what.
  2. Don’t badmouth: Assign responsibility, not blame. Say nothing of another you wouldn’t say to him.
  3. Never assume the motives of others are, to them, less noble than yours are to you.
  4. Expand your sense of the possible.
  5. Don’t trouble yourself with matters you truly cannot change.
  6. Expect no more of anyone than you can deliver yourself.
  7. Tolerate ambiguity.
  8. Laugh at yourself frequently.
/// ---------------------------------------
// Export.h
/// ---------------------------------------
#define DllExport extern "C"
DllExport int ExportTestVersion() {
return 2018 ;
}
// CopyInsertExample.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "vector"
// A counter for the creation of the class Foo
int FooCounter;
class Foo
#include <OneWire.h>
// OneWire DS18S20, DS18B20, DS1822 Temperature Example
//
// http://www.pjrc.com/teensy/td_libs_OneWire.html
//
// The DallasTemperature library can do all this work for you!
// http://milesburton.com/Dallas_Temperature_Control_Library
OneWire ds(6); // on pin 10 (a 4.7K resistor is necessary)
@echo on
set ADDRESS=google.com
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set dt=%%a
set YYYY=%dt:~0,4%
set MM=%dt:~4,2%
set DD=%dt:~6,2%
set HH=%dt:~8,2%
set Min=%dt:~10,2%
set Sec=%dt:~12,2%
@funvill
funvill / SerialRS485TestTeensy.ino
Created August 15, 2017 10:01
A test using the Teensy 3.1 to Sparkfun RS485 breakout to RS485 converter
/**
* Wiring
* ------------------------------------------
* Teensy Pin 0 RX1 ==> RS485 Breakout TX-0
* Teensy Pin 1 TX1 ==> RS485 Breakout RX-1
* Teensy Pin 2 ==> RS485 Breakout RST
* Teensy GND ==> RS485 Breakout GND and G
* Teensy VIN ==> RS485 Breakout 3-5V
*
* RS485 Breakout GND => RS485 Breakout G
// code
int payloadLength = sprintf(outBuf, "POST %s HTTP/1.1\r\nAuthorization: Basic %s","RW1lcnNvbklEOjEy\r\nContent-Length: %u\r\n\r\n%s", SET_VALUE_URL, "RW1lcnNvbklEOjEy", strlen(thisData), thisData);
// output
POST RW1lcnNvbklEOjEy
Content-Length: %u
%s HTTP/1.1
Authorization: Basic /srvice.cgi