Use mysensors built-in nrf24 library for RPi

This commit is contained in:
Marcelo Aquino
2016-09-14 23:26:12 -03:00
parent 4175a5f423
commit fab2112f9b
22 changed files with 4051 additions and 544 deletions
+6
View File
@@ -24,6 +24,7 @@
#include <iostream>
#include <fstream>
#include <sys/stat.h>
#include <time.h>
#include "log.h"
static const char* CONFIG_FILE = MY_LINUX_CONFIG_FILE;
@@ -124,6 +125,11 @@ void hwWriteConfig(int adr, uint8_t value)
}
}
void hwRandomNumberInit()
{
randomSeed(time(NULL));
}
// Not supported!
int8_t hwSleep(unsigned long ms)
{
+1
View File
@@ -44,6 +44,7 @@ void hwReadConfigBlock(void* buf, void* adr, size_t length);
void hwWriteConfigBlock(void* buf, void* adr, size_t length);
uint8_t hwReadConfig(int adr);
void hwWriteConfig(int adr, uint8_t value);
void hwRandomNumberInit();
#ifdef MY_RF24_IRQ_PIN
static pthread_mutex_t hw_mutex = PTHREAD_MUTEX_INITIALIZER;
+14 -5
View File
@@ -72,6 +72,15 @@ static int daemonize(void)
return 0;
}
void print_usage()
{
printf("Usage: mysGateway [options]\n\n" \
"Options:\n" \
" -h Display a short summary of all program options.\n" \
" -d Enable debug.\n" \
" -b Become a daemon.\n");
}
int main(int argc, char *argv[])
{
int opt, log_opts, debug = 0, foreground = 1;
@@ -83,11 +92,7 @@ int main(int argc, char *argv[])
while ((opt = getopt(argc, argv, "hdb")) != -1) {
switch (opt) {
case 'h':
printf("Usage: mysGateway [options]\n\n" \
"Options:\n" \
"-h Display a short summary of all program options.\n" \
"-d Enable debug.\n" \
"-b Become a daemon.\n");
print_usage();
exit(0);
case 'd':
debug = 1;
@@ -95,11 +100,15 @@ int main(int argc, char *argv[])
case 'b':
foreground = 0;
break;
default:
print_usage();
exit(0);
}
}
log_opts = LOG_CONS;
if (foreground && isatty(STDIN_FILENO)) {
// Also print syslog to stderror
log_opts |= LOG_PERROR;
}
if (!debug) {
+1 -5
View File
@@ -20,11 +20,7 @@
#include "MyConfig.h"
#include "MyTransport.h"
#ifdef __linux__
#include "drivers/RF24/RF24_Linux.h"
#else
#include "drivers/RF24/RF24.h"
#endif
#include "drivers/RF24/RF24.h"
#include "drivers/CircularBuffer/CircularBuffer.h"