This file contains hidden or 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
| FROM node:16 | |
| #Create app directory | |
| WORKDIR /usr/src/app | |
| #Install any dependencies | |
| COPY . . | |
| RUN npm install |
This file contains hidden or 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
| require('lightrun').start({ | |
| lightrunSecret: '<YOUR_LIGHTRUN_SECRET>', | |
| company: '<YOUR_COMPANY_NAME>', | |
| }); | |
| const express = require('express'); | |
| const req = require('express/lib/request'); | |
| const app = express(); | |
| let bodyParser = require('body-parser'); |
This file contains hidden or 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
| public function addUser(Request $request) { | |
| $username1 = $request->get('username'); | |
| $username2 = $request->get('remoteUsername'); | |
| $exists = User::where('username',$username2)->first(); | |
| $callingUser = User::where('username',$username1)->first(); | |
| $uuid1 = $callingUser->uuid; | |
| if($exists) { | |
| $uuid2 = $exists->uuid; | |
| $pubnub = new PubnubConfig($uuid1); | |
| $pubnub->grantOne($uuid1,$uuid2); |
This file contains hidden or 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
| def systemInit(): | |
| global port, loraM, client | |
| obtain_port() | |
| gpio_init() | |
| emergencyVehicleState.setdefault("state",0) | |
| #loraM handles all the loraEvents | |
| loraM = MCLoRa(port) | |
| success = loraM.testOK() | |
| if success: |
This file contains hidden or 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
| def handleEmergencyMessage(client, userdata, msg): | |
| print(msg.topic + ' ' + str(msg.payload)) | |
| dataReceived = json.loads(msg.payload) | |
| gpsLocation[0] = dataReceived["lat"] | |
| gpsLocation[1] = dataReceived["lon"] | |
| gps_tuple = tuple(gpsLocation) | |
| distanceCalculated = int(vincenty(TRAFFIC_SIGNAL, gps_tuple).meters) | |
| print ("Emergency Vehicle Location: ", distanceCalculated) | |
| if distanceCalculated >= 150: | |
| emergencyVehicleState["state"] = 0 |
This file contains hidden or 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
| def updateTrafficSignal(): | |
| global trafficLightNormalCurrState | |
| state = emergencyVehicleState["state"] | |
| if state == NORMAL: | |
| if (LIGHT_RED == trafficLightNormalCurrState): | |
| print "Switching to RED\n" | |
| set_red() | |
| elif (LIGHT_YELLOW == trafficLightNormalCurrState): | |
| print "Switching to YELLOW\n" |
This file contains hidden or 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
| def loraReceive(): | |
| global loraM | |
| count = 0 | |
| while True: | |
| print "LoRa Packet Receive Start" | |
| try: | |
| data = str(loraM.recv()) | |
| if data == "01": #Code 01 indicates primary communication failure | |
| print "Received LoRa Signal from Emergeny Vehicle" | |
| emergencyVehicleState["state"] = 1 |
This file contains hidden or 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
| document = client.sync \ | |
| .services(SERVICE_SID) \ | |
| .documents("gpsData") \ | |
| .update(data=gps_Data) |
This file contains hidden or 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
| document = client.sync \ | |
| .services(SERVICE_SID) \ | |
| .documents("gpsData") \ | |
| .update(data=gps_Data) |
This file contains hidden or 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
| def systemInit(): | |
| global port, loraM, client | |
| obtain_port() | |
| gpio_init() | |
| emergencyVehicleState.setdefault("state",0) | |
| #loraM handles all the loraEvents | |
| loraM = MCLoRa(port) | |
| success = loraM.testOK() | |
| if success: |
NewerOlder