Bonezegei Search : A Library for Extracting Key Values from Single Strings in Embedded Systems
Batutay, Jofel ยท 2023/10/27

Embedded systems often need to communicate with other devices and parse data from them. However, parsing complex data structures can be challenging and inefficient for embedded systems with limited resources. Bonezegei Search is a simple and lightweight library for Arduino that allows extracting key values from single strings using a delimiter and a separator. For example, a string like "motor1=100, motor2=50, sensor1=25.4" can be parsed by Bonezegei Search using "," as the delimiter and "=" as the separator. The library returns the value associated with a given key as a string, which can then be converted to the appropriate data type. Bonezegei Search can be useful for applications such as robotics, IoT, and sensor networks, where embedded systems need to process data from other devices quickly and reliably.

Disclaimer

The code and libraries provided by Bonezegei is intended for informational and educational purposes only. Bonezegei does not own or manufacture the hardware associated with the code. The code is provided "as is" without any warranty, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement. In no event shall Bonezegei be liable for any claim, damages, or other liability arising from the use of the code or the hardware. Users are solely responsible for ensuring that their use of the code complies with all applicable laws and regulations.


1. Bonezegei Search Basic Usage example

Retrieve values from a single string

/*
  Author: Jofel Batutay (Bonezegei)
  Date: July 2023

  Usage Sample

  Simple Array keyword Search

  Search the keyword in an array and returns its value. The keyword must be unique in    
   the array if the keyword exist multiple times in the array the function will only 
   return the value of the first keyword

  The Library returns the following data types (int, float, char*)
*/

#include <Bonezegei_Search.h>
//data string
char *data = "device=100 Temperature=78.21  name=Bonezegei Search ; ";

Bonezegei_Search search;

void setup() {
  Serial.begin(115200);
  Serial.println("\nBonezegei Search Usage Sample\n");

  // returns integer Value (param1,param2)
  // param1 = array source
  // param2 = the keyword
  int valueInt = search.getInt(data, "device");
  Serial.print("\"device\": ");
  Serial.println(valueInt);

  //returns float Value
  float valueFLoat = search.getFloat(data, "Temperature");
  Serial.print("\"Temperature\": ");
  Serial.println(valueFLoat);

  //returns the first word of the string
  String valueString1 = search.getString(data, "name");
  Serial.print("\"name\": ");
  Serial.println(valueString1);

  //returns the words of the string until the end character
  // getString(param1,param2,param3)
  // param1 = array source
  // param2 = the keyword
  // param3 = end character
  String valueString2 = search.getString(data, "name", ';');
  Serial.print("\"name\": ");
  Serial.println(valueString2);
}

void loop() {
  // put your main code here, to run repeatedly:
}

References

  1. Batutay, Jofel. (2023). Arduino Library Installation. Bonezegei. https://bonezegei.com/?c=resources/tutorial&&d=resources/tutorial/libraries/install&&nav=1
  2. Batutay, Jofel. (2023).Bonezegei SoftSerial. 10.13140/RG.2.2.28003.12325

Cite this

  1. Batutay, Jofel. (2023). Bonezegei Search : A Library for Extracting Key Values from Single Strings in Embedded Systems. ResearchGate. https://doi.org/10.13140/RG.2.2.30336.20487