updated java example
This commit is contained in:
5
arduino-example/.idea/misc.xml
generated
5
arduino-example/.idea/misc.xml
generated
@@ -5,6 +5,11 @@
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<PlatformioProjectSettings>
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
</set>
|
||||
</option>
|
||||
</PlatformioProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
|
||||
1
arduino-example/.pio/build/project.checksum
Normal file
1
arduino-example/.pio/build/project.checksum
Normal file
@@ -0,0 +1 @@
|
||||
ea44dd2727a245b26d975c53e424e4418034b6d2
|
||||
BIN
arduino-example/.pio/build/uno_r4_minima/.sconsign310.dblite
Normal file
BIN
arduino-example/.pio/build/uno_r4_minima/.sconsign310.dblite
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
arduino-example/.pio/build/uno_r4_minima/FrameworkArduino/tinyusb/class/vendor/vendor_device.c.o
vendored
Normal file
BIN
arduino-example/.pio/build/uno_r4_minima/FrameworkArduino/tinyusb/class/vendor/vendor_device.c.o
vendored
Normal file
Binary file not shown.
BIN
arduino-example/.pio/build/uno_r4_minima/FrameworkArduino/tinyusb/class/vendor/vendor_host.c.o
vendored
Normal file
BIN
arduino-example/.pio/build/uno_r4_minima/FrameworkArduino/tinyusb/class/vendor/vendor_host.c.o
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
arduino-example/.pio/build/uno_r4_minima/firmware.bin
Executable file
BIN
arduino-example/.pio/build/uno_r4_minima/firmware.bin
Executable file
Binary file not shown.
BIN
arduino-example/.pio/build/uno_r4_minima/firmware.elf
Executable file
BIN
arduino-example/.pio/build/uno_r4_minima/firmware.elf
Executable file
Binary file not shown.
4440
arduino-example/.pio/build/uno_r4_minima/firmware.map
Normal file
4440
arduino-example/.pio/build/uno_r4_minima/firmware.map
Normal file
File diff suppressed because it is too large
Load Diff
1
arduino-example/.pio/build/uno_r4_minima/idedata.json
Normal file
1
arduino-example/.pio/build/uno_r4_minima/idedata.json
Normal file
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
arduino-example/.pio/build/uno_r4_minima/lib9c8/libWiFiS3.a
Normal file
BIN
arduino-example/.pio/build/uno_r4_minima/lib9c8/libWiFiS3.a
Normal file
Binary file not shown.
BIN
arduino-example/.pio/build/uno_r4_minima/libFrameworkArduino.a
Normal file
BIN
arduino-example/.pio/build/uno_r4_minima/libFrameworkArduino.a
Normal file
Binary file not shown.
Binary file not shown.
BIN
arduino-example/.pio/build/uno_r4_minima/src/main.cpp.o
Normal file
BIN
arduino-example/.pio/build/uno_r4_minima/src/main.cpp.o
Normal file
Binary file not shown.
1
arduino-example/.pio/libdeps/uno_r4_minima/integrity.dat
Normal file
1
arduino-example/.pio/libdeps/uno_r4_minima/integrity.dat
Normal file
@@ -0,0 +1 @@
|
||||
WiFiS3
|
||||
@@ -10,5 +10,8 @@
|
||||
|
||||
[env:uno_r4_minima]
|
||||
platform = renesas-ra
|
||||
board = uno_r4_minima
|
||||
board = uno_r4_wifi
|
||||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
lib_deps =
|
||||
WiFiS3
|
||||
11
arduino-example/src/configure.h
Normal file
11
arduino-example/src/configure.h
Normal file
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// Created by strawmanbobi on 10/14/25.
|
||||
//
|
||||
|
||||
#ifndef ARDUINO_EXAMPLE_CONFIGURE_H
|
||||
#define ARDUINO_EXAMPLE_CONFIGURE_H
|
||||
|
||||
#define SECRET_SSID "Strawmanbobi"
|
||||
#define SECRET_PASS "ghostcicy"
|
||||
|
||||
#endif //ARDUINO_EXAMPLE_CONFIGURE_H
|
||||
77
arduino-example/src/main.cpp
Normal file
77
arduino-example/src/main.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
//
|
||||
// Created by strawmanbobi on 10/14/25.
|
||||
//
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <WiFiS3.h> // Library for the UNO R4 WiFi connectivity
|
||||
#include "configure.h" // Your secret credentials file
|
||||
|
||||
// --- Global Variables ---
|
||||
// Read credentials from the secrets file
|
||||
const char ssid[] = SECRET_SSID;
|
||||
const char pass[] = SECRET_PASS;
|
||||
|
||||
int status = WL_IDLE_STATUS;
|
||||
|
||||
// --- Function to print connection details ---
|
||||
void printWiFiStatus() {
|
||||
// Print the SSID of the network you're attached to
|
||||
Serial.print("SSID: ");
|
||||
Serial.println(WiFi.SSID());
|
||||
|
||||
// Print the UNO R4's IP address
|
||||
IPAddress ip = WiFi.localIP();
|
||||
Serial.print("IP Address: ");
|
||||
Serial.println(ip);
|
||||
|
||||
// Print the received signal strength (RSSI)
|
||||
long rssi = WiFi.RSSI();
|
||||
Serial.print("Signal Strength (RSSI): ");
|
||||
Serial.print(rssi);
|
||||
Serial.println(" dBm");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
while (!Serial); // Wait for serial port to connect
|
||||
|
||||
Serial.println("--- Arduino UNO R4 WiFi: Station Mode ---");
|
||||
|
||||
// Set the board to Wi-Fi Station (client) mode
|
||||
// The WiFiS3 library handles this mode implicitly with WiFi.begin()
|
||||
|
||||
// Attempt to connect to the Wi-Fi network
|
||||
Serial.print("Attempting to connect to SSID: ");
|
||||
Serial.println(ssid);
|
||||
|
||||
// Connect to the Wi-Fi network
|
||||
// This is a blocking call that retries until a connection is made or times out
|
||||
status = WiFi.begin(ssid, pass);
|
||||
|
||||
if (status == WL_CONNECTED) {
|
||||
// If connected successfully
|
||||
Serial.println("\n✅ Connection Successful!");
|
||||
printWiFiStatus();
|
||||
} else {
|
||||
// If connection failed
|
||||
Serial.print("\n❌ Connection Failed! Status: ");
|
||||
Serial.println(status);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
void loop() {
|
||||
// Check WiFi status and attempt to reconnect if disconnected
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
Serial.print("Connection lost. Reconnecting...");
|
||||
status = WiFi.begin(ssid, pass);
|
||||
if (status == WL_CONNECTED) {
|
||||
Serial.println("Reconnected!");
|
||||
printWiFiStatus();
|
||||
}
|
||||
}
|
||||
|
||||
// Your main application logic goes here
|
||||
delay(5000);
|
||||
}
|
||||
@@ -21,6 +21,8 @@ public class IRDecode {
|
||||
|
||||
private static Object mSync = new Object();
|
||||
|
||||
private native String irGetVersion();
|
||||
|
||||
private native int irOpen(int category, int subCate, String fileName);
|
||||
|
||||
private native int irOpenBinary(int category, int subCate, byte[] binaries, int binLength);
|
||||
@@ -49,11 +51,15 @@ public class IRDecode {
|
||||
}
|
||||
|
||||
private IRDecode() {
|
||||
String libPath = "/data/irext/libirda_decoder.so";
|
||||
String libPath = "/data/irext/libir_decode.so";
|
||||
System.out.println("loading decode library " + libPath);
|
||||
System.load(libPath);
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return irGetVersion();
|
||||
}
|
||||
|
||||
public int openFile(int category, int subCate, String fileName) {
|
||||
return irOpen(category, subCate, fileName);
|
||||
}
|
||||
@@ -68,6 +74,10 @@ public class IRDecode {
|
||||
if (null == acStatus) {
|
||||
acStatus = new ACStatus();
|
||||
}
|
||||
// validate ac status
|
||||
if (!validateAcStatus(acStatus, keyCode, changeWindDir)) {
|
||||
return new int[0];
|
||||
}
|
||||
decoded = irDecode(keyCode, acStatus, changeWindDir);
|
||||
}
|
||||
return decoded;
|
||||
@@ -121,6 +131,33 @@ public class IRDecode {
|
||||
return irACGetSupportedWindDirection(acMode);
|
||||
}
|
||||
|
||||
private boolean validateAcStatus(ACStatus acStatus, int keyCode, int changeWindDir) {
|
||||
if (acStatus.getAcPower() != Constants.ACPower.POWER_ON.getValue() &&
|
||||
acStatus.getAcPower() != Constants.ACPower.POWER_OFF.getValue()) {
|
||||
return false;
|
||||
}
|
||||
if (acStatus.getAcMode() < Constants.ACMode.MODE_COOL.getValue() ||
|
||||
acStatus.getAcMode() > Constants.ACMode.MODE_DEHUMIDITY.getValue()) {
|
||||
return false;
|
||||
}
|
||||
if (acStatus.getAcTemp() < Constants.ACTemperature.TEMP_16.getValue() ||
|
||||
acStatus.getAcTemp() > Constants.ACTemperature.TEMP_30.getValue()) {
|
||||
return false;
|
||||
}
|
||||
if (acStatus.getAcWindSpeed() < Constants.ACWindSpeed.SPEED_AUTO.getValue() ||
|
||||
acStatus.getAcWindSpeed() > Constants.ACWindSpeed.SPEED_HIGH.getValue()) {
|
||||
return false;
|
||||
}
|
||||
if (acStatus.getAcWindDir() < Constants.ACSwing.SWING_ON.getValue() ||
|
||||
acStatus.getAcWindDir() > Constants.ACSwing.SWING_OFF.getValue()) {
|
||||
return false;
|
||||
}
|
||||
if (changeWindDir != 0 && changeWindDir != 1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
int ret = 0;
|
||||
System.out.println("This is IR decode test");
|
||||
@@ -14,6 +14,7 @@ public class Constants {
|
||||
|
||||
public static final int ERROR_CODE_SUCCESS = 0;
|
||||
public static final int ERROR_CODE_NETWORK_ERROR = -1;
|
||||
|
||||
public static final int ERROR_CODE_AUTH_FAILURE = 1;
|
||||
public static final int ERROR_CODE_INVALID_CATEGORY = 2;
|
||||
public static final int ERROR_CODE_INVALID_BRAND = 3;
|
||||
@@ -21,6 +22,17 @@ public class Constants {
|
||||
public static final int ERROR_CODE_INVALID_CITY = 5;
|
||||
public static final int ERROR_CODE_INVALID_OPERATOR = 6;
|
||||
|
||||
public static final int ERROR_CODE_INVALID_SESSION = 20;
|
||||
|
||||
public static final String ERROR_CODE_SUCESS_TEXT = "success";
|
||||
public static final String ERROR_CODE_NETWORK_ERROR_TEXT = "network error";
|
||||
public static final String ERROR_CODE_AUTH_FAILUTRE_TEXT = "auth failure";
|
||||
public static final String ERROR_CODE_INVALID_CATEGORY_TEXT = "invalid category";
|
||||
public static final String ERROR_CODE_INVALID_BRAND_TEXT = "invalid brand";
|
||||
public static final String ERROR_CODE_INVALID_PARAMETER_TEXT = "invalid parameter";
|
||||
|
||||
public static final String ERROR_CODE_INVALID_SESSION_TEXT = "invalid decode session";
|
||||
|
||||
public enum CategoryID {
|
||||
AIR_CONDITIONER(1),
|
||||
TV(2),
|
||||
@@ -34,7 +46,10 @@ public class Constants {
|
||||
LIGHT(10),
|
||||
BSTB(11),
|
||||
CLEANING_ROBOT(12),
|
||||
AIR_CLEANER(13);
|
||||
AIR_CLEANER(13),
|
||||
DYSON_SERIES(14),
|
||||
CAMERA(15),
|
||||
HEATER(16);
|
||||
|
||||
private final int id;
|
||||
|
||||
Reference in New Issue
Block a user