--- /dev/null
+#############################################################################
+#
+# Makefile for librf24mesh examples on Raspberry Pi
+#
+# By: TMRh20
+# Date: 2013/09
+#
+# Description:
+# ------------
+# use make all and make install to install the examples
+# You can change the install directory by editing the prefix line
+#
+prefix := /usr/local
+
+ARCH=armv6zk
+ifeq "$(shell uname -m)" "armv7l"
+ARCH=armv7-a
+endif
+
+# Detect the Raspberry Pi from cpuinfo
+#Count the matches for BCM2708 or BCM2709 in cpuinfo
+RPI=$(shell cat /proc/cpuinfo | grep Hardware | grep -c BCM2708)
+ifneq "${RPI}" "1"
+RPI=$(shell cat /proc/cpuinfo | grep Hardware | grep -c BCM2709)
+endif
+
+ifeq "$(RPI)" "1"
+# The recommended compiler flags for the Raspberry Pi
+CCFLAGS=-Ofast -mfpu=vfp -mfloat-abi=hard -march=$(ARCH) -mtune=arm1176jzf-s -std=c++0x
+endif
+
+# define all programs
+PROGRAMS = ${SOURCES:.cpp=}
+SOURCES = ${wildcard *.cpp}
+
+all: ${PROGRAMS}
+
+${PROGRAMS}: ${SOURCES}
+ g++ ${CCFLAGS} -Wall -I../ -lrf24-bcm -lrf24network -lrf24mesh $@.cpp -o $@
+
+clean:
+ rm -rf $(PROGRAMS)
+
+install: all
+ test -d $(prefix) || mkdir $(prefix)
+ test -d $(prefix)/bin || mkdir $(prefix)/bin
+ for prog in $(PROGRAMS); do \
+ install -m 0755 $$prog $(prefix)/bin; \
+ done
+
+.PHONY: install
--- /dev/null
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: NodeData.proto
+
+import sys
+_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
+from google.protobuf import descriptor as _descriptor
+from google.protobuf import message as _message
+from google.protobuf import reflection as _reflection
+from google.protobuf import symbol_database as _symbol_database
+from google.protobuf import descriptor_pb2
+# @@protoc_insertion_point(imports)
+
+_sym_db = _symbol_database.Default()
+
+
+
+
+DESCRIPTOR = _descriptor.FileDescriptor(
+ name='NodeData.proto',
+ package='',
+ serialized_pb=_b('\n\x0eNodeData.proto\"Q\n\x08NodeData\x12\x0e\n\x06nodeID\x18\x01 \x02(\r\x12\r\n\x05vbatt\x18\x02 \x01(\r\x12\x11\n\ttimestamp\x18\x03 \x01(\r\x12\x13\n\x0btemperature\x18\x04 \x01(\r')
+)
+_sym_db.RegisterFileDescriptor(DESCRIPTOR)
+
+
+
+
+_NODEDATA = _descriptor.Descriptor(
+ name='NodeData',
+ full_name='NodeData',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ _descriptor.FieldDescriptor(
+ name='nodeID', full_name='NodeData.nodeID', index=0,
+ number=1, type=13, cpp_type=3, label=2,
+ has_default_value=False, default_value=0,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ _descriptor.FieldDescriptor(
+ name='vbatt', full_name='NodeData.vbatt', index=1,
+ number=2, type=13, cpp_type=3, label=1,
+ has_default_value=False, default_value=0,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ _descriptor.FieldDescriptor(
+ name='timestamp', full_name='NodeData.timestamp', index=2,
+ number=3, type=13, cpp_type=3, label=1,
+ has_default_value=False, default_value=0,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ _descriptor.FieldDescriptor(
+ name='temperature', full_name='NodeData.temperature', index=3,
+ number=4, type=13, cpp_type=3, label=1,
+ has_default_value=False, default_value=0,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=18,
+ serialized_end=99,
+)
+
+DESCRIPTOR.message_types_by_name['NodeData'] = _NODEDATA
+
+NodeData = _reflection.GeneratedProtocolMessageType('NodeData', (_message.Message,), dict(
+ DESCRIPTOR = _NODEDATA,
+ __module__ = 'NodeData_pb2'
+ # @@protoc_insertion_point(class_scope:NodeData)
+ ))
+_sym_db.RegisterMessage(NodeData)
+
+
+# @@protoc_insertion_point(module_scope)
--- /dev/null
+
+#include <time.h>
+#include <sys/time.h>
+
+#include <RF24Mesh/RF24Mesh.h>
+#include <RF24Network/RF24Network.h>
+#include <RF24/RF24.h>
+
+
+
+
+#define RFCHANNEL 60 // Prof. White's Gateway
+//#define RFCHANNEL 97 // default RF24Mesh channel
+
+#define MSG_BUFFER_SIZE 1024
+
+
+
+RF24 radio(22, 0);
+RF24Network network(radio);
+RF24Mesh mesh(radio, network);
+
+
+void timestamp(void) {
+ static int buflen = 128;
+ char buffer[buflen];
+ struct timespec ts;
+
+ timespec_get(&ts, TIME_UTC);
+ strftime(buffer, buflen, "%FT%T.", gmtime(&ts.tv_sec));
+ printf("%s%09u ", buffer, (unsigned int)ts.tv_nsec);
+}
+
+
+int main(int argc, char** argv) {
+ uint8_t buffer[MSG_BUFFER_SIZE];
+ size_t msglen=0;
+
+ mesh.setNodeID(0);
+ mesh.begin();
+ mesh.setChannel(RFCHANNEL);
+
+ while (true) {
+ mesh.update();
+ mesh.DHCP();
+
+ while (network.available()) {
+ timestamp();
+ RF24NetworkHeader header;
+ network.peek(header);
+
+ printf("%i NA %i %o ",
+ radio.getChannel(),
+ mesh.getNodeID(header.from_node),
+ header.from_node);
+
+ msglen = network.read(header, buffer, MSG_BUFFER_SIZE);
+
+ size_t i;
+ for (i=0; i<msglen; i++) {
+ printf("%02X", buffer[i]);
+ }
+
+ printf("\n");
+ }
+
+ delay(0);
+ }
+
+ return 0;
+}
+
+