Skip to content

Commit

Permalink
LocalFileSystem renamed LocalFile, minor changes to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gioblu committed Feb 15, 2019
1 parent 141a051 commit 5a6e127
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 35 deletions.
28 changes: 15 additions & 13 deletions documentation/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,25 @@ In the example above the PJON object is instantiated passing [SoftwareBitBang](/
| [ThroughSerialAsync](/src/strategies/ThroughSerialAsync) | Electrical/radio impulses over wire/air | [TSDL](../src/strategies/ThroughSerial/specification/TSDL-specification-v2.1.md) | 1 or 2 |
| [ThroughLoRa](/src/strategies/ThroughLoRa) | Radio impulses over air | LoRa | 3 or 4 |
| [ESPNOW](/src/strategies/ESPNOW) | Radio impulses over air | [ESPNOW](https://www.espressif.com/en/products/software/esp-now/overview) | WiFi link |
| [LocalFile](/src/strategies/LocalFile) | Shared file system (for testing, simulation or inter-process communication) | None | None |
| [Any](/src/strategies/Any) | Virtual inheritance, any of the above | Any of the above | Any of the above |

By default all strategies are included except `ThroughLoRa` and `ESPNOW`. To reduce memory footprint add for example `#define PJON_INCLUDE_SWBB` before PJON inclusion to include only `SoftwareBitBang` strategy. More than one strategy related constant can defined in the same program if that is required.
By default all strategies are included except `LocalFile`, `ThroughLoRa` and `ESPNOW`. To reduce memory footprint add for example `#define PJON_INCLUDE_SWBB` before PJON inclusion to include only `SoftwareBitBang` strategy. More than one strategy related constant can defined in the same program if that is required.

Supported definitions:
- `PJON_INCLUDE_SWBB` includes SoftwareBitBang
- `PJON_INCLUDE_AS` includes AnalogSampling
- `PJON_INCLUDE_ETCP` includes EthernetTCP
- `PJON_INCLUDE_GUDP` includes GlobalUDP
- `PJON_INCLUDE_LUDP` includes LocalUDP
- `PJON_INCLUDE_OS` includes OverSampling
- `PJON_INCLUDE_TS` includes ThroughSerial
- `PJON_INCLUDE_TSA` includes ThroughSerialAsync
- `PJON_INCLUDE_TL` includes ThroughLoRa
- `PJON_INCLUDE_EN` includes ESPNOW
- `PJON_INCLUDE_ANY` includes Any
- `PJON_INCLUDE_NONE` no strategy file included
- `PJON_INCLUDE_SWBB` includes `SoftwareBitBang`
- `PJON_INCLUDE_AS` includes `AnalogSampling`
- `PJON_INCLUDE_ETCP` includes `EthernetTCP`
- `PJON_INCLUDE_GUDP` includes `GlobalUDP`
- `PJON_INCLUDE_LUDP` includes `LocalUDP`
- `PJON_INCLUDE_OS` includes `OverSampling`
- `PJON_INCLUDE_TS` includes `ThroughSerial`
- `PJON_INCLUDE_TSA` includes `ThroughSerialAsync`
- `PJON_INCLUDE_TL` includes `ThroughLoRa`
- `PJON_INCLUDE_EN` includes `ESPNOW`
- `PJON_INCLUDE_ANY` includes `Any`
- `PJON_INCLUDE_LF` includes `LocalFile`
- `PJON_INCLUDE_NONE` does not include any strategy

Before using `ThroughLoRa` be sure to have [arduino-LoRa](https://github.com/sandeepmistry/arduino-LoRa) source available and to have defined the `PJON_INCLUDE_TL` constant before including `PJON.h`.

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include <stdint.h>
// #define LINUX On Mac and Linux
#define PJON_INCLUDE_LOCAL

/* Define the LINUX constant if compiling on Mac or Linux
#define LINUX */

#define PJON_INCLUDE_LF
#include "PJON.h"

bool didReceive = false;
Expand All @@ -26,15 +29,15 @@ static void receiver_function(uint8_t *payload, uint16_t length, const PJON_Pack
if(lastReceivedVal != (val - 1)) {
printf("Warning, we missed something, val: %d, received: %d\n", val, lastReceivedVal);
errorCnt++;
}
}

lastReceivedVal = val;

didReceive = lastReceivedVal==endVal;
}

int main(int argc, char** argv)
{
int main(int argc, char** argv)
{
busId = atoi(argv[1]);
endVal = atoi(argv[2]);
pingpong = atoi(argv[3]);
Expand All @@ -44,7 +47,7 @@ int main(int argc, char** argv)
testBus.set_receiver(receiver_function);
testBus.begin();

printf("Init done waiting for %d responses\n", endVal);
printf("Init done waiting for %d responses\n", endVal);
while (!didReceive) {
// Be 'nice' to other processes
std::this_thread::sleep_for(std::chrono::milliseconds(50));
Expand All @@ -70,5 +73,5 @@ int main(int argc, char** argv)
// Be 'nice' to other processes
std::this_thread::sleep_for(std::chrono::milliseconds(50));
};
return errorCnt;
}
return errorCnt;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <stdint.h>
#include <chrono>
#include <thread>

// #define LINUX On Mac and Linux
#define PJON_INCLUDE_LOCAL
#define PJON_INCLUDE_LF
#include "PJON.h"

bool didReceive = false;
Expand All @@ -16,19 +16,19 @@ static void receiver_function(uint8_t *payload, uint16_t length, const PJON_Pack
didReceive = true;
}

int main(int argc, char** argv)
{
int main(int argc, char** argv)
{
sendings = atoi(argv[1]);
clients = atoi(argv[2]);
printf("Sending %d to %d clients and counting errors\n", sendings, clients);
PJON<LocalFile> testBus(1);
testBus.set_receiver(receiver_function);
testBus.begin();
printf("Init done\n");
printf("Init done\n");
char tosend[100];

for(int cnt = 1; cnt<=sendings;cnt++) {

for(int client = 2; client<=clients; client++) {
sprintf(tosend, "hello %d, sending %d and some stuff", client, cnt);
int result = PJON_BUSY;
Expand All @@ -46,5 +46,5 @@ int main(int argc, char** argv)
}
}
printf("Sender done, total errors: %d\n", errors);
return errors;
}
return errors;
}
8 changes: 4 additions & 4 deletions src/strategies/PJON_Strategies.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
#if defined(PJON_INCLUDE_EN)
#include "ESPNOW/ESPNOW.h"
#endif
#if defined(PJON_INCLUDE_LOCAL)
#include "LocalFileSystem/LocalFile.h"
#if defined(PJON_INCLUDE_LF)
#include "LocalFile/LocalFile.h"
#endif
#if defined(PJON_INCLUDE_NONE)
/* None for custom strategy inclusion */
Expand All @@ -68,8 +68,8 @@
!defined(PJON_INCLUDE_OS) && !defined(PJON_INCLUDE_SWBB) && \
!defined(PJON_INCLUDE_TS) && !defined(PJON_INCLUDE_NONE) && \
!defined(PJON_INCLUDE_TSA) && !defined(PJON_INCLUDE_DUDP) && \
!defined(PJON_INCLUDE_LOCAL)
!defined(PJON_INCLUDE_LF)

#include "Any/Any.h"
#include "AnalogSampling/AnalogSampling.h"
#include "OverSampling/OverSampling.h"
Expand Down
2 changes: 1 addition & 1 deletion src/strategies/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ A strategy is an abstraction layer used to physically transmit data. Thanks to t
| [ThroughSerialAsync](ThroughSerialAsync) | Electrical/radio impulses over wire/air | [TSDL](ThroughSerial/specification/TSDL-specification-v2.1.md) | 1 or 2 |
| [ThroughLoRa](ThroughLoRa) | Radio impulses over air | LoRa | 3 or 4 |
| [ESPNOW](ESPNOW) | Radio impulses over air | [ESPNOW](https://www.espressif.com/en/products/software/esp-now/overview) | WiFi link |
| [LocalFileSystem](LocalFileSystem) | Shared file system | PJDL | None |
| [LocalFile](LocalFile) | Shared file system | PJDL | None |
| [Any](Any) | Virtual inheritance, any of the above | Any of the above | Any of the above |

A `Strategy` is a class containing a set of methods used to physically send and receive data along with the required getters to handle retransmission and collision:
Expand Down

0 comments on commit 5a6e127

Please sign in to comment.