Skip to content

CentralHub

Ahmed Khalil edited this page Apr 25, 2018 · 4 revisions

CentralHub is the app's MainActivity. When an SMS or Slack message is received by the SMSComIN or SlackService classes, they are sent to the NLP for decoding. The Natural Language Processor (NLP) then files back the response, which is reported to CentralHub that then allocates the appropriate activity or service that must be started while passing the necessary parameters as an intent. Moreover, the user can manually enter their command on this activity's main screen rather than messaging it. Once the user hits the SEND button, the command is sent to the NLP. This can also be repeated through speech.

This class is written entirely in Kotlin.

class CentralHub : AppCompatActivity()

onCreate()

This method sets up the app's layout view. Furthermore, within it, the RobotController activity intent is declared. This method also checks for the presence of all the necessary permissions for the app to function without fail. To listen for any broadcasts from the NLP, the receiver is set up here.

fun mockSend(view: View)

This function sends the typed or spoken command to the NLP.

private val NLPReceiver = object : BroadcastReceiver()

This is a local broadcast receiver receiving results from Natural Language Process service.

private fun startDeliveryBot(action: String, contact: String)

This function is for starting a robot controlling activity corresponding to intent "pickup".

  • Parameters:
    • action: the name of the action return from NLP server
    • contact: the contact info where the messages will be delivered