Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorporate improvements from @soshial/@tripplet + myself #151

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a505b93
elaborate differences between protocols
soshial Jun 6, 2021
36dba09
add support of traccar Ignition ON/OFF
soshial Jun 20, 2021
c43738d
Merge branch 'stanleyhuangyc:master' into traccar_integration
soshial Jun 28, 2021
f41758a
Merge pull request #1 from soshial/patch-1
soshial Jun 28, 2021
95fdefe
fix sending incorrect temperature
soshial Jun 30, 2021
ad300ec
payload checksum must always be 2 symbols
soshial Jun 30, 2021
8febac3
include signal strength in the payload
soshial Jun 30, 2021
ea1b0e6
show WiFi status in Freematics Builder
soshial Jun 30, 2021
f5c052c
fix storage dumping; send latest location together with ping
soshial Jul 11, 2021
ff6ca8a
send EVENT_LOW_BATTERY if battery almost discharged
soshial Jul 18, 2021
4794b39
send local timestamp back to server
soshial Sep 10, 2021
a216440
Merge branch 'stanleyhuangyc:master' into traccar_integration
soshial Sep 10, 2021
e6ca381
improve sending time; send cell tower info
soshial Oct 16, 2021
3fb43e3
stop sending RSSI for events
soshial Oct 16, 2021
b285e68
Merge remote-tracking branch 'soshial/traccar_integration'
ndoo Jan 12, 2022
851c882
FreematicsPlus: Fix buzzer frequency being hardcoded at 2000Hz
ndoo Jan 12, 2022
58360d7
FreematicsPlus: Add buzzer volume control
ndoo Jan 12, 2022
7145f7b
Update to fix door slam causing false wakeups
wally2511 Apr 27, 2021
478c8d0
Improve OBD polling
tripplet Jul 3, 2021
6c0df5d
telelogger v5: Abstract voltage update code
ndoo Jan 12, 2022
1e4626b
telelogger v5: Fix "Instable connection" spelling --> "Unstable conne…
ndoo Jan 12, 2022
5c52d52
telelogger v5: Report sync time for UDP transmit, to prevent "Unstabl…
ndoo Jan 12, 2022
3f751f5
telelogger v5: Increase buffer length to accommodate new PIDs
ndoo Jan 12, 2022
51c2548
telelogger v5: Add customizable startup beep sequence
ndoo Jan 12, 2022
3ee98ad
FreematicsPlus: Wait 2 seconds for co-processor GNSS, to match extern…
ndoo Jan 12, 2022
b2fcd7a
telelogger v5: Don't print "GNSS OFF" when GNSS kept on with `GNSS_AL…
ndoo Jan 12, 2022
8bfa33b
telelogger v5: Use new battery voltage routine during ping, works wit…
ndoo Jan 12, 2022
4e56b8d
telelogger v5: Ignore voltage thresholds below USB voltage to allow t…
ndoo Jan 12, 2022
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
5 changes: 3 additions & 2 deletions firmware_v5/telelogger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ Data Transmissions
------------------

Data transmission over UDP and HTTP protocols are implemented with following hardware.

* WiFi (ESP32 built-in)
* WiFi Mesh (ESP-MDF for ESP32)
* 3G WCDMA (SIM5360)
* 4G LTE CAT-4 (SIM7600)
* 4G LTE CAT-M1 (SIM7070)

UDP mode implements a client for [Freematics Hub](https://freematics.com/hub/). HTTP mode implements a client for [Traccar](https://www.traccar.org) under [OsmAnd](https://www.traccar.org/osmand/) protocol.
There two ways of sending data:
1. UDP mode implements a `freematics` protocol client for [Freematics Hub](https://freematics.com/hub/) or [Traccar](https://www.traccar.org) (sends more data, [protocol's API](https://freematics.com/pages/hub/api/), uses 5170 port).
2. HTTP/HTTPS mode implements a `osmand` protocol client for Traccar (sends only location data, [protocol's API](https://www.traccar.org/osmand/), uses 5055 port)

Data Storage
------------
Expand Down
8 changes: 6 additions & 2 deletions firmware_v5/telelogger/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Circular Buffer Configuration
**************************************/
#define BUFFER_SLOTS 32 /* max number of buffer */
#define BUFFER_LENGTH 128 /* bytes per slot */
#define BUFFER_LENGTH 256 /* bytes per slot */
#define SERIALIZE_BUFFER_SIZE 1024 /* bytes */

/**************************************
Expand Down Expand Up @@ -132,7 +132,9 @@
// motion threshold for waking up
#define MOTION_THRESHOLD 0.4f /* moving vehicle motion threshold in G */
// engine jumpstart voltage
#define JUMPSTART_VOLTAGE 14 /* V */
#define JUMPSTART_VOLTAGE 13.5f /* V */
#define LOW_BATTERY_VOLTAGE 11.6f /* V */
#define USB_VOLTAGE 5.0f /* V, don't consider voltages below this, assume we are debugging on USB */

/**************************************
* Additional features
Expand All @@ -142,6 +144,8 @@
#define PIN_SENSOR1 34
#define PIN_SENSOR2 26

#define BEEP_TABLE {2000} /* Hz, each value is a 100ms cycle (use "0" to add gaps) */

#define COOLING_DOWN_TEMP 65 /* celsius degrees */

#define ENABLE_BLE 0
Expand Down
8 changes: 7 additions & 1 deletion firmware_v5/telelogger/dashboard/dashboard.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,14 @@ function processInput(data)
if (ret = checkData(con, "HTTPD:")) {
document.getElementById("wifi").innerHTML = ret.indexOf("NO") >= 0 ? imgCross : imgTick;
}
if (ret = checkData(con, "Joining")) {
document.getElementById("wifi").innerText = ret;
}
if (ret = checkData(con, "WiFi IP:")) {
document.getElementById("wifi").innerHTML = imgTick + " IP:" + ret;
document.getElementById("wifi").innerHTML += " " + imgTick + " IP:" + ret;
}
if (ret = checkData(con, "No WiFi")) {
document.getElementById("wifi").innerHTML = imgCross;
}
if (ret = checkData(con, "IMEI:")) {
document.getElementById("sim_card").innerHTML = imgTick;
Expand Down
22 changes: 17 additions & 5 deletions firmware_v5/telelogger/teleclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,14 @@ bool TeleClientUDP::notify(byte event, const char* payload)
netbuf.init(128);
netbuf.header(devid);
netbuf.dispatch(buf, sprintf(buf, "EV=%X", (unsigned int)event));
// ticker time in milliseconds
netbuf.dispatch(buf, sprintf(buf, "TS=%lu", millis()));
// local device time in seconds
struct timeval timeval1;
gettimeofday(&timeval1, NULL);
uint32_t timestampSec = timeval1.tv_sec;
netbuf.dispatch(buf, sprintf(buf, "TM=%lu", timestampSec));
netbuf.dispatch(buf, sprintf(buf, "ID=%s", devid));
if (rssi) {
netbuf.dispatch(buf, sprintf(buf, "SSI=%d", (int)rssi));
}
if (vin[0]) {
netbuf.dispatch(buf, sprintf(buf, "VIN=%s", vin));
}
Expand Down Expand Up @@ -209,10 +212,18 @@ bool TeleClientUDP::notify(byte event, const char* payload)
if (event == EVENT_LOGIN) {
// extract info from server response
char *p = strstr(data, "TM=");
unsigned long t_seconds = 0;
unsigned long t_microseconds = 0;
if (p) {
t_seconds = atol(p + 3);
}
p = strstr(data, "TN=");
if (p) {
t_microseconds = atol(p + 3);
}
if (t_seconds > 0) {
// set local time from server
unsigned long tm = atol(p + 3);
struct timeval tv = { .tv_sec = (time_t)tm, .tv_usec = 0 };
struct timeval tv = { .tv_sec = (time_t)t_seconds, .tv_usec = (time_t)t_microseconds };
settimeofday(&tv, NULL);
}
p = strstr(data, "SN=");
Expand Down Expand Up @@ -283,6 +294,7 @@ bool TeleClientUDP::transmit(const char* packetBuffer, unsigned int packetSize)
txBytes += packetSize;
txCount++;
success = true;
lastSyncTime = millis();
}
return success;
}
Expand Down
3 changes: 2 additions & 1 deletion firmware_v5/telelogger/teleclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define EVENT_COMMAND 5
#define EVENT_ACK 6
#define EVENT_PING 7
#define EVENT_LOW_BATTERY 8

#define BUFFER_STATE_EMPTY 0
#define BUFFER_STATE_FILLING 1
Expand Down Expand Up @@ -183,4 +184,4 @@ class TeleClientHTTP : public TeleClient
#endif
private:
bool started = false;
};
};
2 changes: 1 addition & 1 deletion firmware_v5/telelogger/telelogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class CStorageRAM: public CStorage {
void tailer()
{
//if (m_cache[m_cacheBytes - 1] == ',') m_cacheBytes--;
m_cacheBytes += sprintf(m_cache + m_cacheBytes, "*%X", (unsigned int)checksum(m_cache, m_cacheBytes));
m_cacheBytes += sprintf(m_cache + m_cacheBytes, "*%02X", (unsigned int)checksum(m_cache, m_cacheBytes));
}
void untailer()
{
Expand Down
Loading