https://toitlang.org/ logo
data package ploblem
# help
u
Hi,im having ploblem with installing container datacake "package mqtt not found"
Copy code
PS C:\Users\bossc\PycharmProjects\python posn\newfolder\.packages\github.com\kasperl\toit-datacake\0.1.2\src> jag container install datacake service.toit
Installing container 'datacake' from 'service.toit' on 'fierce-egg' ...
C:\Users\bossc\PycharmProjects\python posn\newfolder\.packages\github.com\kasperl\toit-datacake\0.1.2\package.lock:7:10: error: Package 'github.com/toitware/mqtt-2.1.1' not found
    url: github.com/toitware/mqtt
         ^~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\bossc\PycharmProjects\python posn\newfolder\.packages\github.com\kasperl\toit-datacake\0.1.2\package.lock:11:10: error: Package 'github.com/toitware/toit-cert-roots-1.4.0' not found
    url: github.com/toitware/toit-cert-roots
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
f
Try running
jag pkg install
first
u
Copy code
PS C:\Users\bossc\PycharmProjects\python posn\newfolder> jag pkg install mqtt
Error: Project has already a package with name 'mqtt'
PS C:\Users\bossc\PycharmProjects\python posn\newfolder> jag pkg install datacake
Error: Project has already a package with name 'datacake'
suspecting this
Copy code
sdk: ^2.0.0-alpha.35
prefixes:
  certificate_roots: toit-cert-roots
  mqtt: mqtt
packages:
  mqtt:
    url: github.com/toitware/mqtt
    version: 2.1.1
    hash: 49eab960bb1c27245bfc52e72f6f1ec840492abb
  toit-cert-roots:
    url: github.com/toitware/toit-cert-roots
    version: 1.4.0
    hash: bf41ee60ebba65ba01bc9ba1aa6d697e4cc4a8c7
f
No. Just
jag pkg install
That will install (download) the dependencies.
u
ohh
trying it out
f
Basically: `package.yaml`: a list of dependencies. `package.lock`: the current solution to these dependencies. `pkg install foo`: changes these two files and downloads new dependencies. `pkg install`: installs the dependencies given by the
package.lock
file.
`pkg update`: update
package.lock
to a newer solution.
If you ever get into troubles, it's safe to delete any
.packages
folder. You then just need to run
pkg install
again.
that said: you are currently trying to run a program from within the
.packages
folder. So might not completely apply to your use-case.
u
btw when i tried to run it in main folder it showed up error
f
In the main folder of what?
u
Copy code
PS C:\Users\bossc\toit> jag container install datacake service.toit
Error: no such file or directory: 'service.toit'
Usage:
  jag container install <name> <file> [flags]

Flags:
      --assets string            attach assets to the container
  -D, --define stringArray       define settings to control container on device
  -d, --device string            use device with a given name, id, or address
  -h, --help                     help for install
  -O, --optimization-level int   optimization level (default -1)

PS C:\Users\bossc\toit> jag container install src/service.toit
Error: accepts 2 arg(s), received 1
Usage:
  jag container install <name> <file> [flags]

Flags:
      --assets string            attach assets to the container
  -D, --define stringArray       define settings to control container on device
  -d, --device string            use device with a given name, id, or address
  -h, --help                     help for install
  -O, --optimization-level int   optimization level (default -1)
f
Did you checkout the datacake repository?
I'm guessing you are trying to install the datacake's service without cloning the repository? If yes, then that's something I would like to add to jaguar. Something like
jag container install some-name --git=git://github.com/... service/main.toit
(assuming that the git-url has a
service/main.toit
file) For datacake, the file is in
src/service.toit
, but could/should have a
bin
or
service
directory. That's more standard. See, for example, the dhtxx package: https://github.com/toitware/toit-dhtxx
u
so,i need to clone src file in gitgub into my project folder?
f
If you want to install a third-party program yes. At the moment. An alternative is to use Artemis. The pod-specification allows git-entries and does all the work for you.
I would love to extract the non-Artemis parts of the pod-specification and add it to Toit/Jaguar, but I haven't gotten around it yet.
u
i tried cloning it to my project folder and this time different error occured
Copy code
PS C:\Users\bossc\toit> jag container install datacake src/service.toit
Installing container 'datacake' from 'src/service.toit' on 'fierce-egg' ...
src\service.toit:69:7: error: Missing implementations for interface methods
class DatacakeServiceProvider extends ServiceProvider implements ServiceHandler:
      ^~~~~~~~~~~~~~~~~~~~~~~
<sdk>\system\services.toit:315:3: note: Missing implementation for 'handle'
  handle index/int arguments/any --gid/int --client/int -> any
  ^~~~~~
Compilation failed
f
@kasperl any idea? The package is covered by our health-checks, so I would have assumed that we see this issue there.
independently: from your log it looks like you have
src/service.toit
without any surrounding directory (like
toit-datacake
). Was that on purpose?
u
yeah i clone only 'src' file into folder
f
ok. Probably works for this package, but you usually need the
package.{lock|yaml}
of the package to get its dependencies. This one, for example, needs
toit-cert-roots
and
mqtt
.
But that shouldn't be the reason for the error you are seeing.
Let's see what Kasper has to say.
(and I will try to find some time to reproduce. currently busy...)
k
I think we just fixed the
main
branch without publishing a new release.
The health checks look at
main
, but the version you can fetch through the package manager is too old to work.
u
i just updated it now and it works!!!
and how can i use multiple -D in 1 line
?
f
I think you can just write
jag ... -Dfoo=bar -Dtoto=tata ...
u
ohh thankss
is device-id serial number?
f
context?
u
Copy code
jag container install datacake src/service.toit \
    -D datacake.api.token=...                   \
    -D datacake.device.id=...                   \
    -D datacake.product.slug=...
(from github)
f
Given that it is prefixed with
datacake
I would expect this to be a value (uuid?) that you have given (or that has been given by) datacake. @kasperl ?
u
Copy code
[jaguar] INFO: program bdb72de8-0169-9fcd-ded6-20dc9662b135 started
[reconnect] DEBUG: connected to broker
[reconnect] DEBUG: connection established
[datacake.mqtt] INFO: connected {host: mqtt.datacake.co, port: 8883, client: 1294b972-4728aac}
[datacake.mqtt] INFO: packet published {field: TEMPERATURE, value: 18.0}
DEBUG: closing connection {reason: CANCELED}
[datacake.mqtt] INFO: disconnected {host: mqtt.datacake.co, port: 8883, client: 1294b972-4728aac}
when i use serial number and run example in github it showed up this
and nothing change in datacake dashboard
f
To me this sounds like one of the options to datacake wasn't correct and the server rejected the connection.
Did you get the serial number from the datacake server? Or did you register it there?
u
its from datacake device information
f
ok. good.
and you have the correct product-slug?
Here is the doc on how to find all the information: https://docs.datacake.de/api/internal-mqtt/mqtt
u
thanks i figured it out
datacake device id of mine isnt the same as on datacake url
so i use the url one instead
Copy code
https://app.datacake.de/chatbordin-anancharoenkit/devices/d/73e7ae25-ae22-40e7-9291-a807c7c6aa07/t/dashboard-0
how to make datacake service run before my container?
f
I think the datacake service client automatically waits a bit when it tries to connect to the client. As long as they are started at the same time things should work out. But @kasperl knows more about services.
u
Copy code
EXCEPTION error. 
Cannot find Datacake service
  0: connect                   <pkg:toit-datacake>\datacake.toit:15:18     
  1: main                      new.toit:10:21
******************************************************************************

[jaguar] ERROR: container 'main' stopped - exit code 1
[datacake] INFO: service starting
[datacake] INFO: service running
[wifi] DEBUG: connecting
[wifi] DEBUG: connected
f
Let's hope Kasper has an idea.
u
i just reinstall container and it shows up exception error
Copy code
EXCEPTION error. 
DEADLINE_EXCEEDED
  0: Sleeper_.sleep-until_.<block> <sdk>\core\timer.toit:47:44
  1: Sleeper_.sleep-until_     <sdk>\core\timer.toit:33:3
  2: sleep                     <sdk>\core\timer.toit:9:12
  3: Driver.wait-for-ready_    <pkg:toit-dhtxx>\driver_.toit:150:46        
  4: Driver.read-data-no-catch_ <pkg:toit-dhtxx>\driver_.toit:108:21       
  5: Driver.read-data_.<block>.<block>.<block>.<block> <pkg:toit-dhtxx>\driver_.toit:93:20
  6: Driver.read-data_.<block>.<block>.<block> <pkg:toit-dhtxx>\driver_.toit:91:32
  7: Task_.with-deadline_.<block> <sdk>\core\task.toit:223:16
  8: Task_.with-deadline_      <sdk>\core\task.toit:217:3
  9: with-timeout              <sdk>\core\utils.toit:189:24
 10: with-timeout              <sdk>\core\utils.toit:181:10
 11: Driver.read-data_.<block>.<block> <pkg:toit-dhtxx>\driver_.toit:91:9  
 12: catch.<block>             <sdk>\core\exceptions.toit:124:10
 13: catch                     <sdk>\core\exceptions.toit:122:1
 14: catch                     <sdk>\core\exceptions.toit:73:10
 15: Driver.read-data_.<block> <pkg:toit-dhtxx>\driver_.toit:90:7
 16: SmallInteger_.repeat      <sdk>\core\numbers.toit:1288:3
 17: Driver.read-data_         <pkg:toit-dhtxx>\driver_.toit:89:14
 18: Driver.read-temperature   <pkg:toit-dhtxx>\driver_.toit:67:31
 19: main.<block>              new.toit:15:20
 20: Duration.of               <sdk>\core\time.toit:221:10
 21: Duration.periodic         <sdk>\core\time.toit:276:19
 22: main                      new.toit:13:20
******************************************************************************
f
I just released a new DHT version.
Could you try with that one?
I don't remember why I didn't release it immediately. Maybe it also needs a new SDK release to work properly.
k
I think the client assumes that the service is available when you try to use it. There is an
if-absent
block and no timeout. We could cut it some slack by giving it the usual
ServiceClient.DEFAULT-OPEN-TIMEOUT
timeout.
Something like changing the code that starts here https://github.com/kasperl/toit-datacake/blob/main/src/datacake.toit#L7 with this:
Copy code
import system.services show ServiceResourceProxy ServiceClient
import .internal.api show DatacakeService DatacakeServiceClient

_client_/DatacakeServiceClient? ::= (DatacakeServiceClient).open
    --timeout=ServiceClient.DEFAULT-OPEN-TIMEOUT
    --if_absent=: null