This is code is part of a Technion course project in advanced IoT, implementing a device to read and transmit sensors data from a Formula racing car built by students at Technion - Israel Institute of Technology.
Fork of DISCO-L072CZ-LRWAN1_LoRa_PingPong by
This is code is part of a Technion course project in advanced IoT, implementing a device to read and transmit sensors data from a Formula racing car built by students at Technion - Israel Institute of Technology.
How to install
- Create an account on Mbed: https://os.mbed.com/account/signup/
- Import project into Compiler
- In the Program Workspace select "Formula_Nucleo_Reader"
- Select a Platform like so:
- Click button at top-left
- Add Board
- Search "B-L072Z-LRWAN1" and then "Add to your Mbed Compiler"
- Finally click "Compile", if the build was successful, the binary would download automatically
- To install it on device simply plug it in to a PC, open device drive and drag then drop binary file in it
Diff: SX1276GenericLib/Arduino-mbed-APIs/arduino-util.cpp
- Revision:
- 12:02d779e8c4f6
diff -r 9d7409ebfa57 -r 02d779e8c4f6 SX1276GenericLib/Arduino-mbed-APIs/arduino-util.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SX1276GenericLib/Arduino-mbed-APIs/arduino-util.cpp Sat May 19 11:41:10 2018 +0000 @@ -0,0 +1,99 @@ +#ifdef ARDUINO + +#include <Arduino.h> +#include "arduino-util.h" +#include <cstdarg> +#include <stdio.h> + + +char tmpbuf[160]; +extern int us_getTicker(void); +extern int s_getTicker(void); +extern Stream *ser; + +void +dprintf(const char *format, ...) +{ + static volatile bool busy; + if (busy) + return; + busy = true; + + int secs = s_getTicker(); + int s = secs % 60; + int m = secs / 60; + int h = secs / 3600; + int us = us_getTicker() % 1000000; + + snprintf(tmpbuf, sizeof(tmpbuf)-1, "%02d:%02d:%02d.%.06d ", h, m, s, us); + ser->write(tmpbuf, (int) sizeof "00:00:34.3436868 " -1); + + va_list arg; + va_start(arg, format); + int len = vsnprintf(tmpbuf, sizeof(tmpbuf)-3, format, arg); + tmpbuf[len] = '\r'; + tmpbuf[len+1] = '\n'; + tmpbuf[len+2] = 0; + ser->write(tmpbuf, len+3); + va_end(arg); + busy = false; +} + +void +rprintf(const char *format, ...) +{ + va_list arg; + va_start(arg, format); + int len = vsnprintf(tmpbuf, sizeof(tmpbuf)-3, format, arg); + tmpbuf[len] = 0; + ser->write(tmpbuf, len+1); + va_end(arg); +} + +void +dump(const char *title, const void *data, int len) +{ + dprintf("dump(\"%s\", 0x%x, %d bytes)", title, data, len); + + int i, j, cnt; + unsigned char *u; + const int width = 16; + const int seppos = 7; + + cnt = 0; + u = (unsigned char *)data; + while (len > 0) { + rprintf("%08x: ", (unsigned int)data + cnt); + cnt += width; + j = len < width ? len : width; + for (i = 0; i < j; i++) { + rprintf("%2.2x ", *(u + i)); + if (i == seppos) + ser->write(' '); + } + ser->write(' '); + if (j < width) { + i = width - j; + if (i > seppos + 1) + ser->write(' '); + while (i--) { + ser->print(" "); + } + } + for (i = 0; i < j; i++) { + int c = *(u + i); + if (c >= ' ' && c <= '~') + ser->write(c); + else + ser->write('.'); + if (i == seppos) + ser->write(' '); + } + len -= width; + u += width; + ser->print("\r\n"); + } + ser->print("--\r\n"); + +} +#endif