Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions src/Dispatcher.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#include "Dispatcher.h"

#if MESH_PACKET_LOGGING
#include <Arduino.h>
#endif

#include <math.h>

namespace mesh {
Expand Down Expand Up @@ -218,21 +214,22 @@ void Dispatcher::checkRecv() {
}
if (pkt) {
#if MESH_PACKET_LOGGING
Serial.print(getLogDateTime());
Serial.printf(": RX, len=%d (type=%d, route=%s, payload_len=%d) SNR=%d RSSI=%d score=%d time=%d",
MESHCORE_LOG_PRINTF("%s", getLogDateTime());
MESHCORE_LOG_PRINTF(": RX, len=%d (type=%d, route=%s, payload_len=%d) SNR=%d RSSI=%d score=%d time=%d",
pkt->getRawLength(), pkt->getPayloadType(), pkt->isRouteDirect() ? "D" : "F", pkt->payload_len,
(int)pkt->getSNR(), (int)_radio->getLastRSSI(), (int)(score*1000), air_time);

static uint8_t packet_hash[MAX_HASH_SIZE];
pkt->calculatePacketHash(packet_hash);
Serial.print(" hash=");
mesh::Utils::printHex(Serial, packet_hash, MAX_HASH_SIZE);
char hash_hex[MAX_HASH_SIZE*2 + 1];
mesh::Utils::toHex(hash_hex, packet_hash, MAX_HASH_SIZE);
MESHCORE_LOG_PRINTF(" hash=%s", hash_hex);

if (pkt->getPayloadType() == PAYLOAD_TYPE_PATH || pkt->getPayloadType() == PAYLOAD_TYPE_REQ
|| pkt->getPayloadType() == PAYLOAD_TYPE_RESPONSE || pkt->getPayloadType() == PAYLOAD_TYPE_TXT_MSG) {
Serial.printf(" [%02X -> %02X]\n", (uint32_t)pkt->payload[1], (uint32_t)pkt->payload[0]);
MESHCORE_LOG_PRINTF(" [%02X -> %02X]\n", (uint32_t)pkt->payload[1], (uint32_t)pkt->payload[0]);
} else {
Serial.printf("\n");
MESHCORE_LOG_PRINTF("\n");
}
#endif
logRx(pkt, pkt->getRawLength(), score); // hook for custom logging
Expand Down Expand Up @@ -339,14 +336,14 @@ void Dispatcher::checkSend() {
outbound_expiry = futureMillis(max_airtime);

#if MESH_PACKET_LOGGING
Serial.print(getLogDateTime());
Serial.printf(": TX, len=%d (type=%d, route=%s, payload_len=%d)",
MESHCORE_LOG_PRINTF("%s", getLogDateTime());
MESHCORE_LOG_PRINTF(": TX, len=%d (type=%d, route=%s, payload_len=%d)",
len, outbound->getPayloadType(), outbound->isRouteDirect() ? "D" : "F", outbound->payload_len);
if (outbound->getPayloadType() == PAYLOAD_TYPE_PATH || outbound->getPayloadType() == PAYLOAD_TYPE_REQ
|| outbound->getPayloadType() == PAYLOAD_TYPE_RESPONSE || outbound->getPayloadType() == PAYLOAD_TYPE_TXT_MSG) {
Serial.printf(" [%02X -> %02X]\n", (uint32_t)outbound->payload[1], (uint32_t)outbound->payload[0]);
MESHCORE_LOG_PRINTF(" [%02X -> %02X]\n", (uint32_t)outbound->payload[1], (uint32_t)outbound->payload[0]);
} else {
Serial.printf("\n");
MESHCORE_LOG_PRINTF("\n");
}
#endif
}
Expand Down
1 change: 0 additions & 1 deletion src/Mesh.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "Mesh.h"
//#include <Arduino.h>

namespace mesh {

Expand Down
23 changes: 17 additions & 6 deletions src/MeshCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,28 @@
#define MAX_PATH_SIZE 64
#define MAX_TRANS_UNIT 255

#if MESH_DEBUG && ARDUINO
#include <Arduino.h>
#define MESH_DEBUG_PRINT(F, ...) Serial.printf("DEBUG: " F, ##__VA_ARGS__)
#define MESH_DEBUG_PRINTLN(F, ...) Serial.printf("DEBUG: " F "\n", ##__VA_ARGS__)
// Single seam for all of MeshCore's diagnostic output. Platform ports define
// MESHCORE_LOG_PRINTF to whatever their console is; on Arduino it is Serial.
#ifndef MESHCORE_LOG_PRINTF
#ifdef ARDUINO
#include <Arduino.h>
#define MESHCORE_LOG_PRINTF(F, ...) Serial.printf(F, ##__VA_ARGS__)
#else
#include <stdio.h>
#define MESHCORE_LOG_PRINTF(F, ...) printf(F, ##__VA_ARGS__)
#endif
#endif

#if MESH_DEBUG
#define MESH_DEBUG_PRINT(F, ...) MESHCORE_LOG_PRINTF("DEBUG: " F, ##__VA_ARGS__)
#define MESH_DEBUG_PRINTLN(F, ...) MESHCORE_LOG_PRINTF("DEBUG: " F "\n", ##__VA_ARGS__)
#else
#define MESH_DEBUG_PRINT(...) {}
#define MESH_DEBUG_PRINTLN(...) {}
#endif

#if BRIDGE_DEBUG && ARDUINO
#define BRIDGE_DEBUG_PRINTLN(F, ...) Serial.printf("%s BRIDGE: " F, getLogDateTime(), ##__VA_ARGS__)
#if BRIDGE_DEBUG
#define BRIDGE_DEBUG_PRINTLN(F, ...) MESHCORE_LOG_PRINTF("%s BRIDGE: " F, getLogDateTime(), ##__VA_ARGS__)
#else
#define BRIDGE_DEBUG_PRINTLN(...) {}
#endif
Expand Down
3 changes: 0 additions & 3 deletions src/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
#include "nrf_cc310/include/ssi_aes.h"
#endif

#ifdef ARDUINO
#include <Arduino.h>
#endif

namespace mesh {

Expand Down
3 changes: 2 additions & 1 deletion src/helpers/AdvertDataHelpers.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <stdio.h>
#include <string.h>
#include <helpers/AdvertDataHelpers.h>
#include <helpers/UTF8Helpers.h>

Expand Down Expand Up @@ -60,7 +62,6 @@
}
}

#include <Arduino.h>

void AdvertTimeHelper::formatRelativeTimeDiff(char dest[], int32_t seconds_from_now, bool short_fmt) {
const char *suffix;
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/AutoDiscoverRTCClock.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <Mesh.h>
#include <Arduino.h>
#include <stdint.h>
#include <Wire.h>

class AutoDiscoverRTCClock : public mesh::RTCClock {
Expand Down
1 change: 1 addition & 0 deletions src/helpers/BaseChatMesh.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <stdio.h>
#include <helpers/BaseChatMesh.h>
#include <Utils.h>

Expand Down
4 changes: 3 additions & 1 deletion src/helpers/BaseChatMesh.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once

#include <Arduino.h> // needed for PlatformIO
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <Mesh.h>
#include <helpers/AdvertDataHelpers.h>
#include <helpers/TxtDataHelpers.h>
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/BaseSerialInterface.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <Arduino.h>
#include <stddef.h>
#include <stdint.h>

#define MAX_FRAME_SIZE 176 // +4 for transport codes (region scoping)

Expand Down
1 change: 0 additions & 1 deletion src/helpers/ChannelDetails.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include <Arduino.h>
#include <Mesh.h>

struct ChannelDetails {
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/ClientACL.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <Arduino.h> // needed for PlatformIO
#include <stdint.h>
#include <string.h>
#include <Mesh.h>
#include <helpers/IdentityStore.h>

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/ContactInfo.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <Arduino.h>
#include <stdint.h>
#include <Mesh.h>

#define OUT_PATH_UNKNOWN 0xFF
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/MeshadventurerBoard.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <Arduino.h>
#include <stdint.h>

// LoRa radio module pins for Meshadventurer
#define P_LORA_DIO_1 33
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/NRF52Board.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <Arduino.h>
#include <stddef.h>
#include <stdint.h>
#include <MeshCore.h>

#if defined(NRF52_PLATFORM)
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/RTC_RX8130CE.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#ifndef __RTC_RX8130CE_H__
#define __RTC_RX8130CE_H__

#include <Arduino.h>
#include <stddef.h>
#include <stdint.h>
#include <Wire.h>
#include <time.h>
#include "RTClib.h"
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/TransportKeyStore.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <Arduino.h> // needed for PlatformIO
#include <stdint.h>
#include <Packet.h>
#include <helpers/IdentityStore.h>

Expand Down
6 changes: 4 additions & 2 deletions src/helpers/TxtDataHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ bool StrHelper::isBlank(const char* str) {
return true;
}

#include <Arduino.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

union int32_Float_t
{
Expand Down Expand Up @@ -102,7 +104,7 @@ static void _ftoa(float f, char *p, int *status)
*p++ = '0';
else
{
ltoa(int_part, p, 10);
snprintf(p, 12, "%ld", (long)int_part);
while (*p)
p++;
}
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/nrf52/EthernetMac.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <Arduino.h>
#include <stdint.h>

static inline void generateEthernetMac(uint8_t mac[6]) {
uint32_t device_id = NRF_FICR->DEVICEID[0];
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/stm32/InternalFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
* THE SOFTWARE.
*/

#include <Arduino.h>
#include <stdint.h>
#include <string.h>
#include "InternalFileSystem.h"

//--------------------------------------------------------------------+
Expand Down
1 change: 0 additions & 1 deletion src/helpers/ui/DRV2605Vibration.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#ifdef HAS_DRV2605

#include <Arduino.h>
#include <Adafruit_DRV2605.h>

/*
Expand Down
1 change: 0 additions & 1 deletion src/helpers/ui/GenericVibration.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#ifdef PIN_VIBRATION

#include <Arduino.h>

/*
* Vibration motor control class
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/ui/MomentaryButton.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <Arduino.h>
#include <stdint.h>

#define BUTTON_EVENT_NONE 0
#define BUTTON_EVENT_CLICK 1
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/ui/RotaryInput.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <Arduino.h>
#include <stdint.h>

enum class RotaryInputEvent : uint8_t {
None,
Expand Down