Skip to content

Instantly share code, notes, and snippets.

Shyam Purkayastha shyampurk

Block or report user

Report or block shyampurk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Laravel-Vue-AddUser.php
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);
View emer_v_sys_init.py
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:
View hndl_emer_msg.py
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
View upd_traffic_sig.py
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"
View lora_recv.py
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
View doc_update.py
document = client.sync \
.services(SERVICE_SID) \
.documents("gpsData") \
.update(data=gps_Data)
View TwilioSyncEmergncyVehicleLocSync.py
document = client.sync \
.services(SERVICE_SID) \
.documents("gpsData") \
.update(data=gps_Data)
@shyampurk
shyampurk / EmergencyVehicleSystemInit.py
Created Jun 28, 2018
Twilio Sync for Emergency Vehicle Control
View EmergencyVehicleSystemInit.py
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:
@shyampurk
shyampurk / EventCustFeedback-Subscribe
Created Feb 19, 2018
Event Customer Feedback Subscribe
View EventCustFeedback-Subscribe
function pub_subscribe(){
pubnub.subscribe({
channel : channel_output,
message : function(m){
console.log(m);
message_listing(m);
},
error : function (error) {
console.log(JSON.stringify(error));
}
@shyampurk
shyampurk / EventCustFeedback-FormSubmit
Created Feb 19, 2018
Event Customer Feedback Form Submit
View EventCustFeedback-FormSubmit
function pub_publish(pub_msg){
pubnub.publish({
channel : channel_input,
message : pub_msg,
callback : function(m){
console.log(m);
}
});
};
You can’t perform that action at this time.