Control MP Arduino Library

Click here to download the ControlMP library (ControlMP.zip)

For information on how to install the ControlMP library see Installing Additional Arduino Libraries.

Functions:

void BeginUDP(int port, char delimiterChar)
Begins UDP server which sends and receives on the same port. Once a packet is received the remote IP address will be used when sending.
parameters:
  • port - port to send and receive packets.
  • delimiterChar - the delimiter character that is used for commands
void BeginUDP(int port, char delimiterChar, int remotePort, char *remoteAddress)
Begins UDP server you can specify remote port and IP address for sending.
parameters:
  • port - port to send and receive packets.
  • delimiterChar - the delimiter character that is used for commands
  • remotePort - port to use when sending packets
  • remoteAddress - IP address to use when sending packets
void BeginBLE(Stream *output, char delimiterChar)
Begins BLE, this function is used with serial/stream devices like the HM-10.
parameters:
  • output - SoftwareSerial object or any stream attached to a BLE device (be sure to use "&" address of object)
  • delimiterChar - the delimiter character that is used for commands
void BeginBLE(char *deviceName, char *serviceUUID, char *characteristicUUID, char delimiterChar)
Begins BLE, this function is used with the ESP32 only.
parameters:
  • deviceName - will show as the BLE device name
  • serviceUUID - service UUID
  • characteristicUUID - characteristic UUID
  • delimiterChar - the delimiter character that is used for commands
void BeginBLE(char *deviceName, char *serviceUUID, char *characteristicUUID, char delimiterChar, BLEServerCallbacks *pCallbacks)
Begins BLE and accepts a BLEServerCallbacks class for connection state callbacks, this function is used with the ESP32 only.
parameters:
  • deviceName - will show as the BLE device name
  • serviceUUID - service UUID
  • characteristicUUID - characteristic UUID
  • delimiterChar - the delimiter character that is used for commands
  • pCallbacks - a new instance of the BLEServerCallbacks class to receive connection state callbacks
void SetListener(voidFuncPtr callBackFuncitonPointer, char *command)
Sets a command listener and calls the callback function when command is received.
parameters:
  • callBackFuncitonPointer - function to call when command is received.
  • command - the command to listen for, this should be the command string up to the {0} example: TS1:
* Callback function format: void YourFunctionName(char *command, char *data)
parameters:
  • command - will contain the command that was received, example TS1:
  • data - the value that was received for the command
int SendUDP(char *message)
Sends UDP packet using IP address from remote device (must have received a packet from the remote device before using this function), returns bytes sent.
parameters:
  • message - message to send
int SendUDP(char *message, int port, char *address)
Sends UDP packet, returns bytes sent.
parameters:
  • message - message to send
  • port - port to use
  • address - IP address to use
void SendBLE(char *message)
Sends UDP packet, returns bytes sent.
parameters:
  • message - message to send
int GetDataBLE()
Checks to see if any BLE data is available, returns bytes received. This is not used for the ESP32.

int GetDataUDP()
Checks to see if any UDP packets are available, returns bytes received.
Returns number of bytes received

IPAddress GetRemoteIP()
Gets the remote IP address, will return 0.0.0.0 if unknown (remote device did not send a packet yet) or it hasn't been set in the BeginUDP function.
Returns remote IP Address

Debugging Macros

DebugPrint(val)
DebugPrintln(val)
DebugPrintf(val, format)
DebugPrintfln(val, format)

Examples Bluetooth (BLE):

BME280BLE - Example sketch to display enviromental information from a BME280 for the Control MP app using a HM-10 Bluetooth 4 BLE Module. Uses a Toggle Switch component to switch between fahrenheit or celsius.

LEDSimpleHM10 - Example LED sketch for the Control MP app using an Arduino Uno or Nano with a HM-10 BLE module to turn the built in LED on or off using a Toggle Switch component. This example also sends a command back to the Control MP app that turns on a LED in the app and also sends the status of the built in LED (on or off to be displayed in the app using a Dynamic Text component).

LEDSimpleESP32 - Example LED sketch for the Control MP app using an ESP32 to turn the built in LED on or off using a Toggle Switch component. This example also sends a command back to the Control MP app that turns on a LED in the app and also sends the status of the built in LED (on or off to be displayed in the app using a Dynamic Text component).

Examples WiFi (UDP):

LEDSimpleUDP - Example LED sketch for the Control MP app for a ESP32, ESP8266 or Arduino with WIFI using UDP to turn the built in LED on or off using a Toggle Switch component. This example also sends a command back to the Control MP app that turns on a LED in the app and also sends the status of the built in LED (on or off to be displayed in the app using a Dynamic Text component).

LEDSimpleUDP-AP - Example LED sketch for the Control MP app for a ESP32, ESP8266 or Arduino with WIFI (same as above example LEDSimpleUDP but sets the device up as an access point) using UDP to turn the built in LED on or off using a Toggle Switch component. This example also sends a command back to the Control MP app that turns on a LED in the app and also sends the status of the built in LED (on or off to be displayed in the app using a Dynamic Text component).

ServosAccJoy - Example sketch for the Control MP app for ESP32, ESP8266 or Arduino with WIFI to control two servos using a Joystick component for portrait and using the accelerometer for landscape. There is also an accelerometer calibrate button in landscape.

RobotUDP - Example Sketch for the Control MP app for controlling a robot using two motors with differential steering and four servos, a MeArm for example.