mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-24 22:02:30 +00:00
Merge pull request #114 from geeksville/master
Add python API to webpage
This commit is contained in:
commit
7ee2643e9a
@ -13,6 +13,7 @@ Note: Questions after reading this? See our new [forum](https://meshtastic.disco
|
||||
- Applications where closed source GPS communicators just won't cut it (it is easy to add features for glider pilots etc...)
|
||||
- Secure long-range communication within groups without depending on cellular providers
|
||||
- Finding your lost kids ;-)
|
||||
- Through our [python API](https://pypi.org/project/meshtastic/) use these inexpensive radios to easily add mesh networking to your own projects.
|
||||
|
||||
[](https://www.youtube.com/watch?v=WlNbMbVZlHI "Meshtastic early demo")
|
||||
|
||||
@ -38,6 +39,7 @@ This software is 100% open source and developed by a group of hobbyist experimen
|
||||
|
||||
Note: Updates are happening almost daily, only major updates are listed below. For more details see our forum.
|
||||
|
||||
- 04/28/2020 - 0.6.0 [Python API](https://pypi.org/project/meshtastic/) released. Makes it easy to use meshtastic devices as "zero config / just works" mesh transport adapters for other projects.
|
||||
- 04/20/2020 - 0.4.3 Pretty solid now both for the android app and the device code. Many people have donated translations and code. Probably going to call it a beta soon.
|
||||
- 03/03/2020 - 0.0.9 of the Android app and device code is released. Still an alpha but fairly functional.
|
||||
- 02/25/2020 - 0.0.4 of the Android app is released. This is a very early alpha, see below to join the alpha-testers group.
|
||||
|
2
proto
2
proto
@ -1 +1 @@
|
||||
Subproject commit 8427b23016dc96fc78885f05de5172e9eec5fe6d
|
||||
Subproject commit e570ee9836949d9f420fd19cc59a2595c8669a6e
|
@ -17,6 +17,7 @@ void SerialConsole::init()
|
||||
{
|
||||
Port.begin(SERIAL_BAUD);
|
||||
StreamAPI::init();
|
||||
emitRebooted();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,9 +45,6 @@ class PhoneAPI
|
||||
/// We temporarily keep the nodeInfo here between the call to available and getFromRadio
|
||||
const NodeInfo *nodeInfoForPhone = NULL;
|
||||
|
||||
/// Our fromradio packet while it is being assembled
|
||||
FromRadio fromRadioScratch;
|
||||
|
||||
ToRadio toRadioScratch; // this is a static scratch object, any data must be copied elsewhere before returning
|
||||
|
||||
/// Use to ensure that clients don't get confused about old messages from the radio
|
||||
@ -85,6 +82,9 @@ class PhoneAPI
|
||||
void handleSetRadio(const RadioConfig &r);
|
||||
|
||||
protected:
|
||||
/// Our fromradio packet while it is being assembled
|
||||
FromRadio fromRadioScratch;
|
||||
|
||||
/**
|
||||
* Subclasses can use this as a hook to provide custom notifications for their transport (i.e. bluetooth notifies)
|
||||
*/
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "StreamAPI.h"
|
||||
#include "configuration.h"
|
||||
|
||||
#define START1 0x94
|
||||
#define START2 0xc3
|
||||
@ -58,14 +59,33 @@ void StreamAPI::writeStream()
|
||||
do {
|
||||
// Send every packet we can
|
||||
len = getFromRadio(txBuf + HEADER_LEN);
|
||||
if (len != 0) {
|
||||
txBuf[0] = START1;
|
||||
txBuf[1] = START2;
|
||||
txBuf[2] = (len >> 8) & 0xff;
|
||||
txBuf[3] = len & 0xff;
|
||||
|
||||
stream->write(txBuf, len + HEADER_LEN);
|
||||
}
|
||||
emitTxBuffer(len);
|
||||
} while (len);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the current txBuffer over our stream
|
||||
*/
|
||||
void StreamAPI::emitTxBuffer(size_t len)
|
||||
{
|
||||
if (len != 0) {
|
||||
txBuf[0] = START1;
|
||||
txBuf[1] = START2;
|
||||
txBuf[2] = (len >> 8) & 0xff;
|
||||
txBuf[3] = len & 0xff;
|
||||
|
||||
stream->write(txBuf, len + HEADER_LEN);
|
||||
}
|
||||
}
|
||||
|
||||
void StreamAPI::emitRebooted()
|
||||
{
|
||||
// In case we send a FromRadio packet
|
||||
memset(&fromRadioScratch, 0, sizeof(fromRadioScratch));
|
||||
fromRadioScratch.which_variant = FromRadio_rebooted_tag;
|
||||
fromRadioScratch.variant.rebooted = true;
|
||||
|
||||
DEBUG_MSG("Emitting reboot packet for serial shell\n");
|
||||
emitTxBuffer(pb_encode_to_bytes(txBuf + HEADER_LEN, FromRadio_size, FromRadio_fields, &fromRadioScratch));
|
||||
}
|
@ -37,8 +37,6 @@ class StreamAPI : public PhoneAPI
|
||||
uint8_t rxBuf[MAX_STREAM_BUF_SIZE];
|
||||
size_t rxPtr = 0;
|
||||
|
||||
uint8_t txBuf[MAX_STREAM_BUF_SIZE];
|
||||
|
||||
public:
|
||||
StreamAPI(Stream *_stream) : stream(_stream) {}
|
||||
|
||||
@ -61,6 +59,19 @@ class StreamAPI : public PhoneAPI
|
||||
void writeStream();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Send a FromRadio.rebooted = true packet to the phone
|
||||
*/
|
||||
void emitRebooted();
|
||||
|
||||
/**
|
||||
* Send the current txBuffer over our stream
|
||||
*/
|
||||
void emitTxBuffer(size_t len);
|
||||
|
||||
/// Are we allowed to write packets to our output stream (subclasses can turn this off - i.e. SerialConsole)
|
||||
bool canWrite = true;
|
||||
|
||||
/// Subclasses can use this scratch buffer if they wish
|
||||
uint8_t txBuf[MAX_STREAM_BUF_SIZE];
|
||||
};
|
@ -159,6 +159,7 @@ typedef struct _FromRadio {
|
||||
RadioConfig radio;
|
||||
DebugString debug_string;
|
||||
uint32_t config_complete_id;
|
||||
bool rebooted;
|
||||
} variant;
|
||||
} FromRadio;
|
||||
|
||||
@ -289,6 +290,7 @@ typedef struct _ToRadio {
|
||||
#define FromRadio_radio_tag 6
|
||||
#define FromRadio_debug_string_tag 7
|
||||
#define FromRadio_config_complete_id_tag 8
|
||||
#define FromRadio_rebooted_tag 9
|
||||
#define FromRadio_num_tag 1
|
||||
#define ToRadio_packet_tag 1
|
||||
#define ToRadio_want_config_id_tag 100
|
||||
@ -432,7 +434,8 @@ X(a, STATIC, ONEOF, MESSAGE, (variant,my_info,variant.my_info), 3) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (variant,node_info,variant.node_info), 4) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (variant,radio,variant.radio), 6) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (variant,debug_string,variant.debug_string), 7) \
|
||||
X(a, STATIC, ONEOF, UINT32, (variant,config_complete_id,variant.config_complete_id), 8)
|
||||
X(a, STATIC, ONEOF, UINT32, (variant,config_complete_id,variant.config_complete_id), 8) \
|
||||
X(a, STATIC, ONEOF, BOOL, (variant,rebooted,variant.rebooted), 9)
|
||||
#define FromRadio_CALLBACK NULL
|
||||
#define FromRadio_DEFAULT NULL
|
||||
#define FromRadio_variant_packet_MSGTYPE MeshPacket
|
||||
|
Loading…
Reference in New Issue
Block a user