Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: PlaceOS/driver
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v6.8.6
Choose a base ref
...
head repository: PlaceOS/driver
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on May 16, 2023

  1. feat: add a docs workflow

    stakach committed May 16, 2023
    Copy the full SHA
    9d4aaca View commit details

Commits on Jun 27, 2023

  1. feat(management): switch to using unix sockets for IPC

    also improves guarantees of process startup and shutdown
    stakach committed Jun 27, 2023
    Copy the full SHA
    6a0c26c View commit details
  2. Copy the full SHA
    8d8fd5f View commit details

Commits on Jul 19, 2023

  1. Copy the full SHA
    51d113d View commit details
  2. fix(CI): don't install ameba

    stakach committed Jul 19, 2023
    Copy the full SHA
    d84b603 View commit details
  3. Copy the full SHA
    4e2d77d View commit details
  4. Copy the full SHA
    4569b71 View commit details

Commits on Jul 26, 2023

  1. fix(define_setting): serialize to YAML

    as it runs a YAML parser over it on the far end
    stakach committed Jul 26, 2023
    Copy the full SHA
    ba4f2dd View commit details
  2. Copy the full SHA
    d56c954 View commit details

Commits on Oct 12, 2023

  1. Copy the full SHA
    ad64b45 View commit details
  2. Copy the full SHA
    754fbf4 View commit details

Commits on Oct 13, 2023

  1. Copy the full SHA
    7d45dcc View commit details
  2. Copy the full SHA
    727d8a7 View commit details
  3. Copy the full SHA
    9e99e2f View commit details

Commits on Oct 18, 2023

  1. feat(interface/chat_functions): expose data via redis

    for reduced load
    stakach committed Oct 18, 2023
    Copy the full SHA
    3f310b1 View commit details

Commits on Oct 23, 2023

  1. Copy the full SHA
    34bc8ec View commit details
  2. Copy the full SHA
    dcb8788 View commit details
  3. Copy the full SHA
    6b44052 View commit details

Commits on Oct 26, 2023

  1. Copy the full SHA
    e1a4383 View commit details
  2. Copy the full SHA
    5c3c514 View commit details
  3. Copy the full SHA
    5391473 View commit details

Commits on Nov 29, 2023

  1. Copy the full SHA
    8911aa8 View commit details

Commits on Jan 4, 2024

  1. Copy the full SHA
    947ed6e View commit details

Commits on Feb 5, 2024

  1. Copy the full SHA
    8ae6bdf View commit details

Commits on Mar 13, 2024

  1. Copy the full SHA
    257cb18 View commit details

Commits on Apr 3, 2024

  1. fix(sensor): add level to initializer

    building and level
    stakach committed Apr 3, 2024
    Copy the full SHA
    f5a3515 View commit details

Commits on Apr 11, 2024

  1. feat(redis-storage): expose redis internals

    so the client can be shared
    stakach committed Apr 11, 2024
    Copy the full SHA
    8a460e7 View commit details
  2. Copy the full SHA
    f0eaedd View commit details
  3. chore: fix compiler warnings

    stakach committed Apr 11, 2024
    Copy the full SHA
    9363dbe View commit details

Commits on Apr 12, 2024

  1. Copy the full SHA
    8c9f9f1 View commit details

Commits on Jun 20, 2024

  1. Copy the full SHA
    ec756a9 View commit details
  2. Copy the full SHA
    24e994e View commit details

Commits on Jun 21, 2024

  1. Copy the full SHA
    08e6450 View commit details

Commits on Jun 24, 2024

  1. Copy the full SHA
    bbddf68 View commit details

Commits on Jul 16, 2024

  1. Copy the full SHA
    7d17de7 View commit details

Commits on Aug 18, 2024

  1. Copy the full SHA
    703fbe6 View commit details

Commits on Aug 27, 2024

  1. Copy the full SHA
    e24ffba View commit details
  2. Copy the full SHA
    8f7ada5 View commit details

Commits on Sep 12, 2024

  1. Copy the full SHA
    4b6745c View commit details
  2. Copy the full SHA
    dad4ff3 View commit details
  3. Copy the full SHA
    d8a81e3 View commit details
  4. Copy the full SHA
    04ef324 View commit details
  5. Copy the full SHA
    0d5a935 View commit details
  6. Copy the full SHA
    64dd565 View commit details
  7. Copy the full SHA
    5496052 View commit details

Commits on Sep 13, 2024

  1. Copy the full SHA
    bfa81bb View commit details
  2. Copy the full SHA
    10f1f1a View commit details

Commits on Sep 23, 2024

  1. Copy the full SHA
    35f55c7 View commit details
  2. fix(proxy/driver): make __send__ a reserved word

    so issues with cross driver communication are simpler to detect at compile time
    stakach committed Sep 23, 2024
    Copy the full SHA
    10004f0 View commit details

Commits on Oct 24, 2024

  1. Copy the full SHA
    26a53b3 View commit details
Showing with 711 additions and 207 deletions.
  1. +4 −3 .github/workflows/ci.yml
  2. +24 −0 .github/workflows/docs.yml
  3. +5 −4 shard.yml
  4. +2 −2 spec/driver_proxy_spec.cr
  5. +1 −1 spec/helper.cr
  6. +5 −5 spec/logger_spec.cr
  7. +9 −9 spec/process_manager_spec.cr
  8. +3 −3 spec/protocol_management_spec.cr
  9. +2 −2 spec/protocol_spec.cr
  10. +2 −2 spec/subscription_proxy_spec.cr
  11. +5 −5 spec/subscription_spec.cr
  12. +1 −1 spec/system_proxy_spec.cr
  13. +3 −3 spec/test_build.cr
  14. +10 −3 spec/transport_http_spec.cr
  15. +12 −7 src/placeos-driver.cr
  16. +2 −1 src/placeos-driver/constants.cr
  17. +10 −1 src/placeos-driver/driver-specs/mock_driver.cr
  18. +9 −6 src/placeos-driver/driver-specs/runner.cr
  19. +42 −10 src/placeos-driver/driver_manager.cr
  20. +1 −0 src/placeos-driver/driver_model.cr
  21. +70 −0 src/placeos-driver/interface/chat_functions.cr
  22. +21 −0 src/placeos-driver/interface/desk_control.cr
  23. +24 −0 src/placeos-driver/interface/guest_building_access.cr
  24. +2 −2 src/placeos-driver/interface/lighting.cr
  25. +5 −1 src/placeos-driver/interface/lockers.cr
  26. +5 −3 src/placeos-driver/interface/mailer.cr
  27. +57 −0 src/placeos-driver/interface/mailer_templates.cr
  28. +9 −1 src/placeos-driver/interface/sensor.cr
  29. +42 −0 src/placeos-driver/interface/zone_access_security.cr
  30. +4 −6 src/placeos-driver/logger.cr
  31. +1 −1 src/placeos-driver/process_manager.cr
  32. +140 −46 src/placeos-driver/protocol/management.cr
  33. +9 −3 src/placeos-driver/proxy/driver.cr
  34. +1 −1 src/placeos-driver/proxy/drivers.cr
  35. +13 −4 src/placeos-driver/proxy/remote_driver.cr
  36. +31 −4 src/placeos-driver/proxy/subscriptions.cr
  37. +6 −2 src/placeos-driver/storage/redis-storage.cr
  38. +0 −1 src/placeos-driver/subscriptions.cr
  39. +105 −62 src/placeos-driver/transport.cr
  40. +5 −1 src/placeos-driver/transport/http.cr
  41. +8 −0 src/placeos-driver/utilities/discovery.cr
  42. +1 −1 src/placeos-driver/utilities/rescue_from.cr
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -20,15 +20,16 @@ jobs:
stable: [true]
crystal:
- latest
- 1.14.1
include:
- stable: false
crystal: nightly
# Service containers to run with `container-job`
services:
sshtest:
image: tutum/ubuntu:trusty
image: testcontainers/sshd:1.2.0
env:
ROOT_PASS: somepassword
PASSWORD: somepassword
# Label used to access the service container
redis:
# Docker Hub image
@@ -45,7 +46,7 @@ jobs:
run: apk add --no-cache libssh2-static iputils
- uses: actions/checkout@v2
- name: Install dependencies
run: shards install --ignore-crystal-version
run: shards install --ignore-crystal-version --skip-postinstall --skip-executables
- name: Run tests
run: crystal spec -v --error-trace
env:
24 changes: 24 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Deploy docs

on:
push:
branches: [ master ]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: crystal-lang/install-crystal@v1
with:
crystal: latest
- name: "Install shards"
run: shards install
- name: "Generate docs"
run: crystal docs
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
9 changes: 5 additions & 4 deletions shard.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: placeos-driver
version: 6.8.6
crystal: ">= 1.0.0"
version: 7.4.1

dependencies:
action-controller:
@@ -17,8 +16,10 @@ dependencies:
debug:
github: Sija/debug.cr

hound-dog:
github: place-labs/hound-dog
# clustering service discovery
redis_service_manager:
github: place-labs/redis_service_manager
version: ">= 3.0.0"

ipaddress:
github: Sija/ipaddress.cr
4 changes: 2 additions & 2 deletions spec/driver_proxy_spec.cr
Original file line number Diff line number Diff line change
@@ -114,7 +114,7 @@ describe PlaceOS::Driver::Proxy::Driver do
req_out.reply.should eq("reply_id")
req_out.id.should eq("mod-1234")

sleep 0.5
sleep 500.milliseconds

# reply to the execute request
req_out.cmd = :result
@@ -170,7 +170,7 @@ describe PlaceOS::Driver::Proxy::Driver do

# Subscription should not exist yet - i.e. no lookup
subscription.module_id.should eq("mod-1234")
sleep 0.05
sleep 50.milliseconds

# Update the status
mod_store["power"] = true
2 changes: 1 addition & 1 deletion spec/helper.cr
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ class Helper
input.write_bytes json.bytesize
input.write json.to_slice

sleep 0.01
sleep 10.milliseconds

raw_data = Bytes.new(4096)
bytes_read = output.read(raw_data)
10 changes: 5 additions & 5 deletions spec/logger_spec.cr
Original file line number Diff line number Diff line change
@@ -24,13 +24,13 @@ describe PlaceOS::Driver::Log do
# However we still don't want them being logged to our regular logs
(std_out.size > 0).should eq(false)

# Warning and above logs should go to both
logger.warn { "hello-logs" }
# Error and above logs should go to both
logger.error { "hello-logs" }

bytes_read = output.read(raw_data)
req_out = PlaceOS::Driver::Protocol::Request.from_json(String.new(raw_data[2, bytes_read - 4]))
req_out.id.should eq("mod-123")
req_out.payload.should eq(%{[4,"hello-logs"]})
req_out.payload.should eq(%{[5,"hello-logs"]})

(std_out.size > 10).should eq(true)
end
@@ -68,12 +68,12 @@ describe PlaceOS::Driver::Log do
(std_out.size > 0).should eq(false)

# Warning and above logs should go to both
logger.warn { "hello-logs" }
logger.error { "hello-logs" }

bytes_read = output.read(raw_data)
req_out = PlaceOS::Driver::Protocol::Request.from_json(String.new(raw_data[2, bytes_read - 4]))
req_out.id.should eq("mod-123")
req_out.payload.should eq(%{[4,"hello-logs"]})
req_out.payload.should eq(%{[5,"hello-logs"]})

(std_out.size > 10).should eq(true)
end
18 changes: 9 additions & 9 deletions spec/process_manager_spec.cr
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ describe PlaceOS::Driver::ProcessManager do
input.write_bytes json.bytesize
input.write json.to_slice

sleep 0.01
sleep 100.milliseconds
raw_data = Bytes.new(4096)
bytes_read = output.read(raw_data)

@@ -49,7 +49,7 @@ describe PlaceOS::Driver::ProcessManager do
input.write_bytes json.bytesize
input.write json.to_slice

sleep 0.01
sleep 100.milliseconds
raw_data = Bytes.new(4096)
bytes_read = output.read(raw_data)

@@ -68,7 +68,7 @@ describe PlaceOS::Driver::ProcessManager do
input.write json.to_slice

process.loaded[driver_id].logger.debugging.should eq(false)
sleep 0.01
sleep 100.milliseconds
process.loaded[driver_id].logger.debugging.should eq(true)

# Disable debugging
@@ -80,7 +80,7 @@ describe PlaceOS::Driver::ProcessManager do
input.write json.to_slice

process.loaded["mod_1234"].logger.debugging.should eq(true)
sleep 0.01
sleep 100.milliseconds
process.loaded["mod_1234"].logger.debugging.should eq(false)

# Update settings
@@ -101,7 +101,7 @@ describe PlaceOS::Driver::ProcessManager do
input.write json.to_slice

process.loaded[driver_id].settings.json["test"]["number"].as_i.should eq(123)
sleep 0.01
sleep 100.milliseconds
process.loaded[driver_id].settings.json["test"]["number"].as_i.should eq(1234)

# Update settings where the IP address has changed
@@ -122,7 +122,7 @@ describe PlaceOS::Driver::ProcessManager do
input.write json.to_slice

process.loaded[driver_id].settings.json["test"]["number"].as_i.should eq(1234)
sleep 0.01
sleep 100.milliseconds
process.loaded[driver_id].settings.json["test"]["number"].as_i.should eq(12345)

# Check what's running on this node:
@@ -149,7 +149,7 @@ describe PlaceOS::Driver::ProcessManager do
input.write json.to_slice

process.loaded.size.should eq 1
sleep 0.01
sleep 100.milliseconds
process.loaded.size.should eq 0

# Ensure it terminates properly
@@ -185,7 +185,7 @@ describe PlaceOS::Driver::ProcessManager do
input.write_bytes json.bytesize
input.write json.to_slice

sleep 0.01
sleep 10.milliseconds
raw_data = Bytes.new(4096)
bytes_read = output.read(raw_data)

@@ -214,7 +214,7 @@ describe PlaceOS::Driver::ProcessManager do
input.write_bytes json.bytesize
input.write json.to_slice

sleep 0.01
sleep 10.milliseconds
raw_data = Bytes.new(4096)
bytes_read = output.read(raw_data)

6 changes: 3 additions & 3 deletions spec/protocol_management_spec.cr
Original file line number Diff line number Diff line change
@@ -67,7 +67,7 @@ describe PlaceOS::Driver::Protocol::Management do
manager.info.should eq(["mod-management-test"])

manager.stop("mod-management-test")
sleep 0.2
sleep 200.milliseconds
manager.running?.should eq(false)
manager.terminated?.should eq(false)
redis_callback.should eq 0
@@ -115,7 +115,7 @@ describe PlaceOS::Driver::Protocol::Management do
}))
manager.running?.should eq(true)

sleep 0.5
sleep 500.milliseconds

# Clears the module state
redis_clear.should eq 1
@@ -162,7 +162,7 @@ describe PlaceOS::Driver::Protocol::Management do
manager.info.should eq(["mod-management-test"])

manager.stop("mod-management-test")
sleep 0.2
sleep 200.milliseconds
manager.running?.should eq(false)
manager.terminated?.should eq(false)
end
4 changes: 2 additions & 2 deletions spec/protocol_spec.cr
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ describe PlaceOS::Driver::Protocol do
input.write json.to_slice

while id.nil?
sleep 0.001
sleep 10.milliseconds
end

id.should eq("mod_1234")
@@ -53,7 +53,7 @@ describe PlaceOS::Driver::Protocol do
IO.copy(io, input)

while results.size < 2
sleep 0.001
sleep 10.milliseconds
end

input.close
4 changes: 2 additions & 2 deletions spec/subscription_proxy_spec.cr
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ module PlaceOS::Driver::Proxy
channel.close
end

sleep 0.005
sleep 50.milliseconds

RedisStorage.with_redis &.publish("placeos/test", "whatwhat")

@@ -82,7 +82,7 @@ module PlaceOS::Driver::Proxy
sys_lookup[lookup_key] = "mod-1234"
RedisStorage.with_redis &.publish("lookup-change", "sys-123")

sleep 0.05
sleep 50.milliseconds

# Update the status
storage["power"] = true
10 changes: 5 additions & 5 deletions spec/subscription_spec.cr
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ module PlaceOS
channel.close
end

sleep 0.005
sleep 50.milliseconds

Subscriptions.new_redis.publish("placeos/test", "whatwhat")

@@ -86,7 +86,7 @@ module PlaceOS
sys_lookup[lookup_key] = "mod-1234"
redis.publish "lookup-change", "sys-123"

sleep 0.05
sleep 50.milliseconds

# Update the status
storage["power"] = true
@@ -143,11 +143,11 @@ module PlaceOS
# Create the lookup and signal the change
sys_lookup[lookup_key] = "mod-12345"

sleep 0.005
sleep 50.milliseconds

redis.publish "lookup-change", "sys-12345"

sleep 0.005
sleep 50.milliseconds

# Update the status
storage["power"] = true
@@ -163,7 +163,7 @@ module PlaceOS

# Give the loop a moment to start up again
while !subs.running
sleep 0.1
sleep 100.milliseconds
end

in_callback = false
2 changes: 1 addition & 1 deletion spec/system_proxy_spec.cr
Original file line number Diff line number Diff line change
@@ -97,7 +97,7 @@ describe PlaceOS::Driver::Proxy::System do

# Subscription should not exist yet - i.e. no lookup
subscription.module_id.should eq("mod-5678")
sleep 0.05
sleep 50.milliseconds

# Update the status
mod_store["power"] = true
6 changes: 3 additions & 3 deletions spec/test_build.cr
Original file line number Diff line number Diff line change
@@ -41,8 +41,8 @@ class Helper
@username : String = ""
@password : String = ""

accessor thing : Thing, implementing: IncludedAble
accessor main_lcd : Display_1, implementing: Powerable
accessor thing : Array(Thing), implementing: IncludedAble
accessor main_lcd : Display_1
accessor switcher : Switcher
accessor camera : Array(Camera), implementing: [Powerable, Moveable]
accessor blinds : Array(Blind)?
@@ -128,7 +128,7 @@ class Helper
end

def future_add(a : Int32, b : Int32 = 200)
Promise.defer { sleep 0.01; a + b }
Promise.defer { sleep 10.milliseconds; a + b }
end

def future_error
13 changes: 10 additions & 3 deletions spec/transport_http_spec.cr
Original file line number Diff line number Diff line change
@@ -2,8 +2,11 @@ require "./helper"

describe PlaceOS::Driver::TransportHTTP do
it "should perform a secure request" do
responses = 0
queue = Helper.queue
transport = PlaceOS::Driver::TransportHTTP.new(queue, "https://www.google.com.au/", ::PlaceOS::Driver::Settings.new(%({"disable_cookies": true})))
transport = PlaceOS::Driver::TransportHTTP.new(queue, "https://www.google.com.au/", ::PlaceOS::Driver::Settings.new(%({"disable_cookies": true}))) do
responses += 1
end
transport.before_request do |request|
request.hostname.should eq "www.google.com.au"
end
@@ -14,16 +17,19 @@ describe PlaceOS::Driver::TransportHTTP do
response = transport.http(:get, "/")
response.status_code.should eq(200)
transport.cookies.size.should eq 0
responses.should eq 1

# Close the connection
transport.terminate
end

it "should perform an insecure request" do
queue = Helper.queue

responses = 0
# Selected from: https://whynohttps.com/
transport = PlaceOS::Driver::TransportHTTP.new(queue, "http://blog.jp/", ::PlaceOS::Driver::Settings.new("{}"))
transport = PlaceOS::Driver::TransportHTTP.new(queue, "http://blog.jp/", ::PlaceOS::Driver::Settings.new("{}")) do
responses += 1
end
transport.before_request do |request|
request.hostname.should eq "blog.jp"
end
@@ -34,6 +40,7 @@ describe PlaceOS::Driver::TransportHTTP do
response = transport.http(:get, "/")
response.status_code.should eq(200)
(transport.cookies.size > 0).should be_true
responses.should eq 1

# Close the connection
transport.terminate
Loading