You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> Get a Crownstone object by it's id for a user, if it exists.
223
250
224
251
#### async_close_session()
225
252
> Async function. This will close the websession in requestHandler to cleanup nicely after the program has finished.
226
253
227
-
#### reset()
228
-
> Reset the requestHandler parameters in case the cloud instance was cleaned up and needs to be recreated.
229
-
230
254
### Spheres
231
255
232
256
#### async_update_sphere_data()
@@ -240,13 +264,18 @@ A User has the following fields in the cloud lib:
240
264
241
265
### Sphere
242
266
267
+
#### async_update_sphere_presence()
268
+
> Async function. Sync the presence of users in the sphere with the cloud.
269
+
243
270
#### async_get_keys() -> Dict
244
-
> Async function. Returns a dict with the keys of this sphere. The keys can be used for BLE connectivity with the Crownstones.
271
+
> Async function. Returns a dict with the keys of this sphere.
272
+
> The keys can be used for BLE connectivity with the Crownstones.
245
273
246
274
### Crownstones
247
275
248
276
#### async_update_crownstone_data()
249
-
> Async function. Sync the Crownstones with the cloud for a sphere. Calling the function again after init will update the current data.
277
+
> Async function. Sync the Crownstones with the cloud for a sphere.
278
+
> Calling the function again after init will update the current data.
250
279
251
280
#### find(crownstone_name: String) -> Crownstone
252
281
> Return a Crownstone object if one exists by that name.
@@ -257,13 +286,17 @@ A User has the following fields in the cloud lib:
257
286
### Crownstone
258
287
259
288
#### async_turn_on()
260
-
> Async function. Send a command to turn a Crownstone on. To make this work make sure to be in the selected sphere and have Bluetooth enabled on your phone.
289
+
> Async function. Send a command to turn a Crownstone on.
290
+
> To make this work make sure to be in the selected sphere and have Bluetooth enabled on your phone.
261
291
262
292
#### async_turn_off()
263
-
> Async function. Send a command to turn a Crownstone off. To make this work make sure to be in the selected sphere and have Bluetooth enabled on your phone.
293
+
> Async function. Send a command to turn a Crownstone off.
294
+
> To make this work make sure to be in the selected sphere and have Bluetooth enabled on your phone.
264
295
265
-
#### async_set_brightness(value: Float)
266
-
> Async function. Send a command to set a Crownstone to a given brightness level. To make this work make sure to be in the selected sphere and have Bluetooth enabled on your phone.
296
+
#### async_set_brightness(value: Integer)
297
+
> Async function. Send a command to set a Crownstone to a given brightness level.
298
+
> To make this work make sure to be in the selected sphere and have Bluetooth enabled on your phone.
299
+
> The value parameter should be between 0 and 100.
267
300
268
301
### Locations
269
302
@@ -294,21 +327,30 @@ A User has the following fields in the cloud lib:
294
327
> Return a location object if one exists by that id.
295
328
296
329
## Async vs sync
297
-
The lib can be used synchonously and asynchronously.<br>
330
+
The lib can be used synchronously and asynchronously.<br>
331
+
The disadvantage of sync context is that all functions are blocking.
332
+
The program will simply wait until a function is complete. In async context, functions (coroutines) can yield control,
333
+
which means that functions can be "paused" while they are waiting for external data to come in, like data from a server.
334
+
Other functions can then be executed in the meantime. This way the program is always busy.<br>
335
+
298
336
All async functions in the library API functions in this library have the prefix **async_**
299
337
Async functions need to be awaited:
300
338
```Python
301
-
await cloud.spheres.async_update_sphere_data()
339
+
await cloud.async_close_session()
302
340
```
303
341
All the async functions mentioned above can also be used synchronously.<br>
304
-
Sync functions don't have the async prefix. for example:
342
+
Use the `run_async()` function like so:
305
343
```Python
306
-
cloud.initialize()
307
-
cloud.spheres.update_sphere_data()
344
+
from crownstone_cloud import run_async
345
+
346
+
run_async(cloud.async_close_session())
308
347
```
309
348
Make sure to see the examples above!
310
349
311
350
## Testing
351
+
352
+
### Tests are not up-to-date yet for the newest commit, only run for version 1.2.1.
353
+
312
354
To run the tests using tox install tox first by running:
0 commit comments