Skip to content

Commit

Permalink
Merge pull request #120 from maxbundscherer/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
maxbundscherer authored Aug 16, 2022
2 parents 4350ad6 + ff4f885 commit 6c8dae6
Show file tree
Hide file tree
Showing 20 changed files with 953 additions and 193 deletions.
24 changes: 20 additions & 4 deletions docs/independer-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,41 @@ This feature is used to set Gateway in sleep mode (Actor controlled).

1. For this Actor \[P3\] `[msg]` is set to `C;slp`. (send twice)

No available check before sending (\[F23.2\]). Gateway sends no response and goes into sleep mode.
No available check before sending (\[F23.2\]). Gateway sends no response and goes into sleep mode. Gateway accepts these commands only from Gateway-Owner.

#### Clear User Messages on Gateway \[F3.1\]
#### Clear User Messages on Gateway \[F3.2\]

This feature is used to clear user messages from Gateway (Actor controlled).

1. For this Actor \[P3\] `[msg]` is set to `C;clmsg`. (send twice)

No available check before sending (\[F23.2\]). Gateway sends no response and clears user messages.

#### Reset Gateway \[F3.3\]

This feature is used to reset Gateway.

1. For this Actor \[P3\] `[msg]` is set to `C;clgat`. (send twice)

No available check before sending (\[F23.2\]). Gateway sends no response and reset settings. Gateway accepts these commands only from Gateway-Owner.

### Based on Safe message \[P1\]

#### Update Gateway \[F3.1\]
#### Update Gateway \[F1.1\]

This feature is used to update Gateway via wifi (Actor controlled).

1. For this Actor \[P1\] `[msg]` is set to `C;up;$wifiSSID;$wifiPW`. Where `$wifiSSID` is ssid from wifi and `$wifiPW` is wifi password.

No available check before sending (\[F23.2\]). Gateway sends no response and goes into update mode.
No available check before sending (\[F23.2\]). Gateway sends no response and goes into update mode. Gateway accepts these commands only from Gateway-Owner.

#### Init Gateway \[F1.2\]

This feature is used to init Gateway via wifi (Actor controlled).

1. For this Actor \[P1\] `[msg]` is set to `C;init;$wifiSSID;$wifiPW;$id`. Where `$wifiSSID` is ssid from wifi, `$wifiPW` is wifi password and `$id` is gateway-id.

No available check before sending (\[F23.2\]). Gateway sends no response and initializes. Gateway-Owner is set from `[from]`.

### Based on Safe message \[P1\] and Unsafe single message \[P3\]

Expand Down
33 changes: 27 additions & 6 deletions docs/server-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,34 @@

JSON-API Independer Server. Please also visit [escape rules](escape-rules.md).

- `<server-url>/v1/msg/<receiverId>` (GET): Get all messages
- Response `OK`
- `<server-url>/v1/register` (POST): Register Device
- `id`: Independer-ID
- `secret`: Secret
- `version`: Version-String of Actor
- Response `OK-<token>` (string, no json)

- `<server-url>/v1/msg` (POST): Write a message
- `<server-url>/v1/getmsgs` (POST): Get all messages
- `auth-id`: Independer-ID
- `auth-token`: Token
- Response (JSON-Array)
- `receiver`: Receiver of the message
- `author`: Author of the message
- `msg`: Content of the message

- `<server-url>/v1/writemsg` (POST): Write a message
- `auth-id`: Independer-ID
- `auth-token`: Token
- `receiver`: Receiver of the message
- `author`: Author of the message
- `msg`: Content of the message
- Response `OK` (string, no json)

- `<server-url>/v1/clearmsgs` (POST): Clear all messages
- `auth-id`: Independer-ID
- `auth-token`: Token
- Response `OK` (string, no json)

- `<server-url>/v1/clearmsg/<receiverId>` (GET): Clear all messages
- Response `OK`
- `<server-url>/v1/gatewayregister` (POST): Check if Gateway is owned by the user
- `auth-id`: Independer-ID
- `auth-token`: Token
- `gateway-id`: ID of Gateway
- Response `OK` (string, no json) if allowed
3 changes: 2 additions & 1 deletion independer-app/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.pio/
.vscode/
.vscode/
.idea/
2 changes: 2 additions & 0 deletions independer-app/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ lib_deps =
boseji/rBase64@^1.1.1
boseji/xxtea-iot-crypt@^2.0.1
bblanchon/ArduinoJson@^6.19.4
; monitor_filters = esp32_exception_decoder
; build_type = debug

; Gateway Section

Expand Down
41 changes: 31 additions & 10 deletions independer-app/src/application/application-actor.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <ArduinoJson.h>

/*
* ####################################
* Who is near? Section
Expand Down Expand Up @@ -557,7 +555,7 @@ void application_actor_query_msgs_from_internet(String myId)
{

gui_msg_static("Hinweis", "Nachrichten werden\nabgerufen");
String ret = wifi_get_chat_messages(myId, state_wifi_server_url, state_wifi_server_port, state_wifi_server_timeout);
String ret = wifi_get_chat_messages(myId, state_wifi_server_url, state_wifi_server_port, state_wifi_server_timeout, state_wifi_server_device_token);
// Serial.println("Query Messages from Internet: '" + ret + "'");

if (ret != "")
Expand Down Expand Up @@ -649,19 +647,32 @@ void application_actor_query_msgs_from_internet(String myId)
* ####################################
*/

void application_actor_automatic_wifi()
S_WIFI_CONFIG_WRAPPER application_actor_automatic_wifi(boolean s_autoSave)
{

boolean sync_was_on_flag = multi_actor_get_state();

if (sync_was_on_flag)
{
multi_actor_stop();
}

gui_msg_static("Hinweis", "Scanne...");
Serial.println("WiFI AutoSave=" + String(s_autoSave));
Serial.print("Scan start ... ");
int n = WiFi.scanNetworks();
Serial.print(n);
Serial.println(" network(s) found");

if (sync_was_on_flag)
{
multi_actor_start();
}

if (n > 0)
{

String gui_items[n];
String gui_items[n + 1];

gui_items[0] = "[abbrechen]"; // Add go back item

Expand All @@ -685,12 +696,22 @@ void application_actor_automatic_wifi()
S_GUI_INPUT_TEXT t_password_wrapper = gui_input_text("Passwort", "");

if (t_password_wrapper.success == false)
return;
{
return S_WIFI_CONFIG_WRAPPER{false, "", ""};
}

db_save_wifi_settings(t_ssid, t_password_wrapper.value);
if (s_autoSave)
{
Serial.println("Save now WIFI Config");
db_save_wifi_settings(t_ssid, t_password_wrapper.value);
gui_msg_animated("Info", "Einstellungen\ngespeichert", C_GUI_DELAY_MSG_SHORT_I);
}
else
{
Serial.println("Skip now Save WIFI Config");
}

gui_msg_animated("Info", "Einstellungen\ngespeichert", C_GUI_DELAY_MSG_SHORT_I);
return;
return S_WIFI_CONFIG_WRAPPER{true, t_ssid, t_password_wrapper.value};
}
}
}
Expand All @@ -699,5 +720,5 @@ void application_actor_automatic_wifi()
gui_msg_animated("Info", "Keine Netzwerke\ngefunden", C_GUI_DELAY_MSG_MIDDLE_I);
}

return;
return S_WIFI_CONFIG_WRAPPER{false, "", ""};
}
Loading

0 comments on commit 6c8dae6

Please sign in to comment.