Skip to content

Commit

Permalink
Merge pull request #73 from nougatbyte/patch-1
Browse files Browse the repository at this point in the history
Typo fix
  • Loading branch information
sachaw authored Oct 22, 2023
2 parents 0a4451c + cd2cdd7 commit e3866b1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/adapters/iHttpConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class IHTTPConnection extends IMeshDevice {

private readLoop: ReturnType<typeof setInterval> | null;

private peningRequest: boolean;
private pendingRequest: boolean;

private abortController: AbortController;

Expand All @@ -28,7 +28,7 @@ export class IHTTPConnection extends IMeshDevice {
this.portId = "";
this.receiveBatchRequests = false;
this.readLoop = null;
this.peningRequest = false;
this.pendingRequest = false;
this.abortController = new AbortController();

this.log.debug(
Expand Down Expand Up @@ -124,14 +124,14 @@ export class IHTTPConnection extends IMeshDevice {

/** Reads any avaliable protobuf messages from the radio */
protected async readFromRadio(): Promise<void> {
if (this.peningRequest) {
if (this.pendingRequest) {
return;
}
let readBuffer = new ArrayBuffer(1);
const { signal } = this.abortController;

while (readBuffer.byteLength > 0) {
this.peningRequest = true;
this.pendingRequest = true;
await fetch(
`${this.portId}/api/v1/fromradio?all=${
this.receiveBatchRequests ? "true" : "false"
Expand All @@ -145,7 +145,7 @@ export class IHTTPConnection extends IMeshDevice {
},
)
.then(async (response) => {
this.peningRequest = false;
this.pendingRequest = false;
this.updateDeviceStatus(Types.DeviceStatusEnum.DEVICE_CONNECTED);

readBuffer = await response.arrayBuffer();
Expand All @@ -155,7 +155,7 @@ export class IHTTPConnection extends IMeshDevice {
}
})
.catch((e: Error) => {
this.peningRequest = false;
this.pendingRequest = false;
this.log.error(
Types.Emitter[Types.Emitter.readFromRadio],
`❌ ${e.message}`,
Expand Down

0 comments on commit e3866b1

Please sign in to comment.