Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

send hello packet response even if it appears second time #2

Open
wants to merge 1 commit into
base: webhub-windows-fix
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions public/javascripts/RequestHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class RequestHandler {
*/
public async handleRequest(serialPacket: SerialPacket): Promise<SerialPacket> {
// if HELLO packet
if (serialPacket.request_type & RequestType.REQUEST_TYPE_HELLO) {
if (serialPacket.request_type === RequestType.REQUEST_TYPE_HELLO) {
return this.handleHelloPacket(serialPacket);

// if a REST request
Expand Down Expand Up @@ -552,8 +552,12 @@ export class RequestHandler {

// if the hub has already been authenticated with a hello packet, return error
if (this.hub_variables["authenticated"]) {
reject("ALREADY AUTHENTICATED");
return;
// set request type to hello and status to OK
responsePacket.setRequestBit(RequestType.REQUEST_TYPE_HELLO);
responsePacket.setRequestBit(RequestStatus.REQUEST_STATUS_OK);
responsePacket.append(0); // append a 0 for OK

resolve(responsePacket); // resolve the response packet to be sent to the bridge micro:bit
}

// if the school ID is blank
Expand Down