MS Iot Device Can Platform

Overview

Kavo MS IoT Platform

Version: 2.0
Author: Luke Garceau

Requirements

  1. Read CAN messages in real-time

  2. Convert the given variables to engineering useful variables

     - useTime
     - runTime
     - idleTime
     - hygieneCycle Data
     - error messages
     - location data
    
  3. Keep the device updated with its cloud counterpart

     - Start MS service on startup
     - Verify MS continues to run
     - Reestablish connection losses from lost wifi
     - Collects data generated during connection losses and transfers the data when connections are reestablished __Todo__
    
  4. Send engineered variables to Iot Central

  5. Dynamically update IP tables with correct MS IP addresses

Overall Concept

  1. Connect to Iot Central and Initialize Can Bus
  2. Split each task into a seperate Thread
  3. Run the Threads using parallelism

Parallelism is the idea of running multiple processes at the same time
Transfer of data between each process is acheived by shared mutex variables (aka constant variables that each thread has access to)

  1. Shared Variables

     - const.CAN_DATA
     - const.CAN_CODES
     - const.MSG_TO_SEND
     - const.MSG_TO_RECORD
    

Pseudo Code

Shared Variables

  • const.CAN_DATA
    - Starts in readCan.py -> readData()
    - List of tuple variables that are to be interpretted into english
    - Ends in hexToEng.py -> interpret()
  • const.MSG_TO_SEND
    - Starts in hexToEng.py -> interpret()
    - List of arrays formatted like:
    [
    ['runTime', '0.008333333333333333']
    ]
    or
    [
    ['runTime', '0.008333333333333333']
    , (comma seperated)
    ['timestamp', '2019-11-06T03:40:29.863497']
    ['hygieneLast', '-1']
    ['hygieneType', 'no_mem']
    ['hygieneStart', 'no_mem']
    ['hygieneStop', 'no_mem']
    ]
    - Can have multiple messages
    - Ends in sendIotc.py -> sendMessages()
  • const.MSG_TO_RECORD
    - Starts in hexToEng.py -> interpret() -> alreadyHave()
    - List of tuple variables to be written to the .csv file
    - Ends in recordData.py -> recordData()

Read CAN Messages

  1. Translate CAN Hex Code to format below:
    Python Tuple of Strings Object
    (Timestamp, CanID, Message)
  2. Append The Tuple to const.MSG_TO_RECORD shared program variable
  3. Append The Tuple to const.MSG_TO_SEND shared program variable

Interpret Messages to Useful Variables

  • runTime
    - Sent every interval in config.ini

  • useTime and idleTime
    - Figured out using hexToEng.py -> alreadyHave()
    - Sent every interval in config.ini

  • hygiene data
    - Update message sent every interval in config.ini
    - Records data to text file start|stop|type -> data/hygieneData.txt
    - Sends hygieneEvent and updates data once a hygiene cycle is triggered on the chair
    - ???What about the hygiene last message???

  • error messages
    - Sends an error message json variable everytime there is a new error message
    - See hexToEng.py -> interpret()

  • location data
    - Pulls user inputted data about the device from the device twin
    - Cloud Properties

              - officeName
              - officeLocation
              - roomName
              - deviceName ???Is this pulled from the cloud or the device?? The device should already have a unique device name on it
    
  • Remove the can message from const.CAN_DATA

Record Data to .csv file

  • Will record new can messages to the .csv file in data/***.csv
  • Format of fileName: (should match old format alpha010_11112019_133131.csv deviceID_mmddyyyy_hhmmss.csv) deviceName = socket.gethostname()
    timestamp = datetime.datetime.now()
    timestamp = '%i-%i-%i_%i:%i' % (timestamp.year, timestamp.month, timestamp.day, timestamp.hour, timestamp.minute) fileName = '%s_canData_%s.csv' % (deviceName, timestamp)
  • Message needs to be of this format: (should match old format 07/25/2019 18:31:08:031 ID: 0x08 Message: 00 06 c0 00 00 00 00 00 timestamp in 1 column, can message in 2nd column ) String:
    YYYY-MM-DD HH-MM-SS.MMMM ID: Ox### Message: ## ## ## ## ## ## ## ##
    • Syntax to format a Can Message:
      incoming canMessage: data = (tuple of strings)
      canTS = data[0]
      canID = data[1]
      canMG = data[2]
      formatMsg = '%s\tID: %s\tMessage: %s\n' % (canTS, canID, canMG)
  • Remove the can message from const.MSG_TO_RECORD

Send To Iot Central

  1. Pull down the device twin from Iot Central

  2. Send the init messages: ???Why are you sending mac, wireless mac and ip address??

     - Location Data: (officeName, roomName, officeLocation, deviceID)
     - Ip Address
     - Hardware Mac Address
     - Wireless Mac Address
     - deviceInit message
    
  3. Loop through all messages in const.MSG_TO_SEND

  4. Append the deviceID to each message

  5. If msg in property list: ['hygieneStart, hygieneStop', 'hygieneLast', 'batteryLevel', 'serialNum']
    - True: Send message as a property - False: Send message as telemetry

  6. Send lastTimeConnected property

  7. Remove message from const.MSG_TO_SEND

Calculation / Determination of UseTime and IdleTime (Im not sure I understand the logic. It looks like it will only send Idle time)

I use a deviceState variable which is of data type String, which has 3 values

    - Use
    - Idle
    - IdlePending

Scenario 1:

Time (minutes since boot) Whats Happening deviceState
0 Device Boot N/A
1 Device Reads initial new can codes/messages Use
1+1ms Device sees starts to see old can messages Idle Pending
5 (use threshold) Device sends useTime message Idle
12 (useThreshold + idlethreshold) Device sends idleTime message Idle

Scenario 2:

Time (minutes since boot) Whats Happening deviceState
0 Device Boot N/A
1 Device Reads initial new can codes/messages Use
1+1ms Device sees starts to see old can messages IdlePending
3 New Can Message Comes through IdlePending
3 cont. UseTimeDelta updated IdleTimeStart reset IdlePending
3+1ms Device sees old can id/message IdlePending
5 (or useThreshold) Device sends useTime message Idle
12 (useThreshold + idleThreshold) Device sends idleTime message if no new code Idle
Owner
Luke Garceau
UNCC 21 A computer science student who just can't get enough of coding.
Luke Garceau
Official ProtonVPN Linux app

ProtonVPN Linux App Copyright (c) 2021 Proton Technologies AG This repository holds the ProtonVPN Linux App. For licensing information see COPYING. Fo

ProtonVPN 288 Jan 01, 2023
Tiny JSON RPC via HTTP library.

jrpc Simplest ever possible Asynchronous JSON RPC via HTTP library for Python, backed by httpx. Installation pip install async-jrpc Usage Import JRPC

Onigiri Team 2 Jan 31, 2022
Script and library to wait for a DNS authority server to get its configuration.

DNSWait dnswait is a small script to wait for the "propagation" of a namserver configuration. Installing It's as easy as: python -m pip install dnswai

Julien Palard 14 Jan 17, 2022
Asyncer, async and await, focused on developer experience

Asyncer, async and await, focused on developer experience. Documentation: https:

Sebastián Ramírez 895 Dec 28, 2022
DataShare - Simple library for data sharing between scripts and public functions calling

DataShare - Simple library for data sharing between scripts and public functions calling. Installation. Install code, Delete LICENSE, README, readme.t

Ivan Perzhinsky. 1 Dec 17, 2021
This is a python based command line Network Scanner utility, which input as an argument for the exact IP address or the relative IP Address range you wish to do the Network Scan for and returns all the available IP addresses with their MAC addresses on your current Network.

This is a python based command line Network Scanner utility, which input as an argument for the exact IP address or the relative IP Address range you wish to do the Network Scan for and returns all t

Abhinandan Khurana 1 Feb 09, 2022
Arp-spoofing, this script was written for people who want to spoof any vulnerable machine such as Wİndows, of course it could have been more sophisticatedly created but these repos will be updated constantly

ARP-SPOOF ARP spoofing is a type of attack in which a malicious actor sends falsified ARP (Address Resolution Protocol) messages over a local area net

2 Dec 28, 2021
Ipscanner - A simple threaded IP-Scanner written in python3 that can monitor local IP's in your network

IPScanner 🔬 A simple threaded IP-Scanner written in python3 that can monitor lo

4 Dec 12, 2022
Top server mcpe Indonesia!

server_mcpe Top server mcpe Indonesia! install pkg install python pkg install git git clone https://github.com/Latip176/server_mcpe cd server_mcpe pip

Muhammad Latif Harkat 2 Jul 17, 2022
JF⚡can - Super fast port scanning & service discovery using Masscan and Nmap. Scan large networks with Masscan and use Nmap's scripting abilities to discover information about services. Generate report.

Description Killing features Perform a large-scale scans using Nmap! Allows you to use Masscan to scan targets and execute Nmap on detected ports with

377 Jan 03, 2023
MoreIP 一款基于Python的面向 MacOS/Linux 用户用于查询IP/域名信息的日常渗透小工具

MoreIP 一款基于Python的面向 MacOS/Linux 用户用于查询IP/域名信息的日常渗透小工具

xq17 9 Sep 21, 2022
E4GL3OS1NT - Simple Information Gathering Tool

E4GL30S1NT Features userrecon - username reconnaissance facedumper - dump facebook information mailfinder - find email with specific name godorker - d

C0MPL3XDEV 195 Dec 21, 2022
BaseSpec is a system that performs a comparative analysis of baseband implementation and the specifications of cellular networks.

BaseSpec is a system that performs a comparative analysis of baseband implementation and the specifications of cellular networks. The key intuition of BaseSpec is that a message decoder in baseband s

SysSec Lab 35 Dec 06, 2022
Simple threaded Python Rickroll server. Listens on port 23 by default.

Terminal Rickroll Simple threaded Python Rickroll server. Listens on port 23 by default. Rickroll video made using Video-To-Ascii and the standard ric

AG 10 Sep 13, 2022
With the use of this tool, you can change your MAC address

Akshat0404/MAC_CHANGER This tool has to be used on linux kernel. Now o

1 Jan 25, 2022
this is demo of tool dosploit for test and dos in network with python

this tool for dos and pentest vul SKILLS: syn flood udp flood $ git clone https://github.com/amicheh/demo_dosploit/ $ cd demo_dosploit $ python3 -m pi

yaser amir chehrazi 5 Sep 22, 2022
A database-based CDN node supporting PostgreSQL and MongoDB backends.

A simple to use database-based deployable CDN node for hobbyist developers who wish to have their own CDN!

Vish M 10 Nov 19, 2022
A simple, configurable application and set of services to monitor multiple raspberry pi's on a network.

rpi-info-monitor A simple, configurable application and set of services to monitor multiple raspberry pi's on a network. It can be used in a terminal

Kevin Kirchhoff 11 May 22, 2022
This Tool Help To Information gathering for domain name or ip address...

Owl-Eye This Tool Help To Information gathering for domain name or ip address... follow this command $apt update && upgrade $apt install python apt in

Black Owl 6 Nov 12, 2022
ExtDNS synchronizes labeled records in docker-compose with DNS providers.

ExtDNS for docker-compose ExtDNS synchronizes labeled records in docker-compose with DNS providers. Inspired by External DNS, ExtDNS makes resources d

DNTSK 6 Dec 24, 2022