From 8b58af297e1cad81d7a7ea702703702c5797593c Mon Sep 17 00:00:00 2001 From: Rodrigo Alfonso Date: Tue, 2 Jan 2024 05:01:48 -0300 Subject: [PATCH] deactivate() now returns a boolean --- README.md | 2 +- lib/LinkWireless.hpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4c1ddd3..be43a8b 100644 --- a/README.md +++ b/README.md @@ -195,7 +195,7 @@ Name | Return type | Description --- | --- | --- `isActive()` | **bool** | Returns whether the library is active or not. `activate()` | **bool** | Activates the library. When an adapter is connected, it changes the state to `AUTHENTICATED`. It can also be used to disconnect or reset the adapter. -`deactivate()` | - | Deactivates the library. +`deactivate()` | **bool** | Puts the adapter into a low consumption mode and then deactivates the library. It returns a boolean indicating whether the transition to low consumption mode was successful. `serve([gameName], [userName], [gameId])` | **bool** | Starts broadcasting a server and changes the state to `SERVING`. You can, optionally, provide a `gameName` (max `14` characters), a `userName` (max `8` characters), and a `gameId` *(0 ~ 0x7FFF)* that games will be able to read. `getServers(servers, [onWait])` | **bool** | Fills the `servers` array with all the currently broadcasting servers. This action takes 1 second to complete, but you can optionally provide an `onWait()` function which will be invoked each time VBlank starts. `getServersAsyncStart()` | **bool** | Starts looking for broadcasting servers and changes the state to `SEARCHING`. After this, call `getServersAsyncEnd(...)` 1 second later. diff --git a/lib/LinkWireless.hpp b/lib/LinkWireless.hpp index d7734de..ed3b103 100644 --- a/lib/LinkWireless.hpp +++ b/lib/LinkWireless.hpp @@ -238,13 +238,15 @@ class LinkWireless { return success; } - void deactivate() { - sendCommand(LINK_WIRELESS_COMMAND_BYE); + bool deactivate() { + bool success = sendCommand(LINK_WIRELESS_COMMAND_BYE).success; lastError = NONE; isEnabled = false; resetState(); stop(); + + return success; } bool serve(std::string gameName = "",