Skip to content

Commit

Permalink
Added reboot command
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan6sha committed May 28, 2023
1 parent eabd115 commit 5fe72c1
Show file tree
Hide file tree
Showing 7 changed files with 450 additions and 301 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ repositories {
dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'com.github.functionland:fula-build-aar:1.8.0' // From jitpack.io
implementation 'com.github.functionland:fula-build-aar:1.9.0' // From jitpack.io
implementation 'com.github.functionland:wnfs-build-aar:v1.4.1' // From jitpack.io
implementation 'commons-io:commons-io:20030203.000550'
// implementation files('mobile.aar')
Expand Down
16 changes: 16 additions & 0 deletions android/src/main/java/land/fx/fula/FulaModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -1365,4 +1365,20 @@ public void wifiRemoveall(Promise promise) {
});
}

@ReactMethod
public void reboot(Promise promise) {
ThreadUtils.runOnExecutor(() -> {
Log.d("ReactNative", "reboot");
try {
byte[] result = this.fula.reboot();
String resultString = toString(result);
Log.d("ReactNative", "result string="+resultString);
promise.resolve(resultString);
} catch (Exception e) {
Log.d("ReactNative", e.getMessage());
promise.reject(e);
}
});
}

}
32 changes: 32 additions & 0 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,38 @@ const App = () => {
}}
color={inprogress ? 'green' : 'blue'}
/>

<Button
title={inprogress ? 'Getting...' : 'Reboot'}
onPress={async () => {
try {
if (initComplete) {
fula.checkConnection().then((r) => {
console.log('connection check');
console.log(r);
if (r) {
console.log(
'initialization is completed. send reboot command'
);
fxblox
.reboot()
.then((res) => {
console.log('reboot received');
console.log(res);
})
.catch((e) => {
console.log('reboot failed');
console.log(e);
});
}
});
} else {
console.log('wait for init to complete');
}
} catch (e) {}
}}
color={inprogress ? 'green' : 'blue'}
/>
</View>
</View>
);
Expand Down
48 changes: 40 additions & 8 deletions src/interfaces/fulaNativeModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface FulaNativeModule {
autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write
useRelay: boolean | null, // if true it forces the use of relay
refresh: boolean // if true it forces to refresh the fula object
) => Promise<string>;
) => Promise<string>;
isReady: (filesystemCheck: boolean) => Promise<boolean>;
logout: (identity: string, storePath: string) => Promise<boolean>;
checkFailedActions: (retry: boolean, timeout: number) => Promise<boolean>;
Expand Down Expand Up @@ -47,7 +47,7 @@ interface FulaNativeModule {

shutdown: () => Promise<void>;

//Blockchain related functions
//Blockchain related functions
createAccount: (seed: string) => Promise<string>;
checkAccountExists: (account: string) => Promise<string>;
createPool: (seed: string, poolName: string) => Promise<string>;
Expand All @@ -56,15 +56,47 @@ interface FulaNativeModule {
leavePool: (seed: string, poolID: number) => Promise<string>;
cancelPoolJoin: (seed: string, poolID: number) => Promise<string>;
listPoolJoinRequests: (poolID: number) => Promise<string>;
votePoolJoinRequest: (seed: string, poolID: number, account: string, accept: boolean) => Promise<string>;
newReplicationRequest: (seed: string, poolID: number, replicationFactor: number, cid: string) => Promise<string>;
newStoreRequest: (seed: string, poolID: number, uploader: string, cid: string) => Promise<string>;
votePoolJoinRequest: (
seed: string,
poolID: number,
account: string,
accept: boolean
) => Promise<string>;
newReplicationRequest: (
seed: string,
poolID: number,
replicationFactor: number,
cid: string
) => Promise<string>;
newStoreRequest: (
seed: string,
poolID: number,
uploader: string,
cid: string
) => Promise<string>;
listAvailableReplicationRequests: (poolID: number) => Promise<string>;
removeReplicationRequest: (seed: string, poolID: number, cid: string) => Promise<string>;
removeStorer: (seed: string, storer: string, poolID: number, cid: string) => Promise<string>;
removeStoredReplication: (seed: string, uploader: string, poolID: number, cid: string) => Promise<string>;
removeReplicationRequest: (
seed: string,
poolID: number,
cid: string
) => Promise<string>;
removeStorer: (
seed: string,
storer: string,
poolID: number,
cid: string
) => Promise<string>;
removeStoredReplication: (
seed: string,
uploader: string,
poolID: number,
cid: string
) => Promise<string>;

//Hardware
bloxFreeSpace: () => Promise<string>;
wifiRemoveall: () => Promise<string>;
reboot: () => Promise<string>;
}

const LINKING_ERROR =
Expand Down
Loading

0 comments on commit 5fe72c1

Please sign in to comment.