-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added examples for the SMC and Socket classes
- Loading branch information
1 parent
773a410
commit d60641c
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# System Managment Controller (SMC) | ||
|
||
Change the power LED behavior (the LED in the middle of the power button): | ||
```C++ | ||
void Init() | ||
{ | ||
// Play to boot animation where all 4 LEDs turn on and off then make the power LED blink | ||
XexUtils::SMC::SetPowerLED(PowerLED_Blink, true); | ||
} | ||
``` | ||
|
||
Set the color of the 4 LEDs around the power button (the ones that turn on when controllers are connected): | ||
```C++ | ||
void Init() | ||
{ | ||
XexUtils::SMC::SetLEDColors(LEDColor_Off, LEDColor_Red, LEDColor_Green, LEDColor_Orange); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Socket | ||
|
||
Connect to a server through insecure sockets and exchange data: | ||
```C++ | ||
void Init() | ||
{ | ||
HRESULT hr = S_OK; | ||
|
||
// Create the socket | ||
uint16_t port = 12345; | ||
XexUtils::Socket socket("<ip_address>", port); | ||
|
||
// Connect to the server | ||
hr = socket.Connect(); | ||
if (FAILED(hr)) | ||
{ | ||
XexUtils::Log::Error("Couldn't connect to server"); | ||
return; | ||
} | ||
|
||
// Send a packet | ||
const char packet[] = "hello world"; | ||
int bytesSent = socket.Send(packet, sizeof(packet)); | ||
if (bytesSent != sizeof(packet)) | ||
{ | ||
XexUtils::Log::Error("Not all packets were sent"); | ||
socket.Disconnect(); | ||
return; | ||
} | ||
|
||
// Wait for the server to process the request and send a response | ||
Sleep(500); | ||
|
||
// Receive the response | ||
char buffer[4096] = { 0 }; | ||
int bytesReceived = socket.Receive(buffer, sizeof(buffer)); | ||
if (bytesReceive == -1) | ||
{ | ||
XexUtils::Log::Error("Couldn't receive the server response"); | ||
socket.Disconnect(); | ||
return; | ||
} | ||
|
||
// Do something with what is inside buffer | ||
|
||
socket.Disconnect(); | ||
} | ||
``` |