Loading...
 
Skip to main content

Initial remote communication C code development

Initial C code development for remote communications


C code function

The purpose of the C code development has been to provide example code for a set of functions that can be copied/adapted by the developers of hub device software to provide remote communication integration with a central Tiki instance. The code development has been focused upon enabling the usage scenarios described here. The objective is that, by using standard ‘C’, this can provide a common code base that can be easily deployed, with almost none or only very minor changes, to a variety of local hub hardware platforms.

The current C code versions have been developed on a Raspberry Pi 5 single board computer (SBC) and compiled using gcc, either to produce:

  • a shared .so library that can be 'called' from a main Python program, or simply to produce
  • an executable main 'C' program using all the 'C' functions


The exact same set of 'C' functions have been shown to operate consistently on a Raspberry Pi 5 SBC, Raspberry Pi 4 SBC, a Raspberry Pi 4 Compute Module, a Raspberry Pi Zero SBC, an NVIDIA Jetson Nano development kit, and an NVIDIA Orin development kit.

The C code now available for download from here consists of the following set of functions:

  • long int findSize(const char* file_name) - a simple function to get the size of a file
  • char* copyString(char s[]) - a simple function to copy a string
  • void removeString (char text[], int index, int rm_length) - a function to remove characters from a string at a designated position
  • void connect_iot() - a simple 'connection' function, included only for test purposes, that just prints out the following message: "Hello - you are now connected to the YYMMDD version of the control IoT C functions…
  • char* webpage_download(int debug, const char* domain, const char* page, char* access_token) - a function that downloads the contents and associated 'wiki' parameters of a web page
  • Bool webpage_check(int debug, const char* domain, const char* page, char* access_token, const char* check_text) - a function to check a web page content looking for specific content on a page and returns 0 if false or 1 if true
  • char* webpage_datetimecheck(int debug, const char* domain, const char* page, char* access_token, const char* infront_text, int datelen, const char* ref_datetime, const char* datetime_fmt) - a function to check a web page content looking for a specific date (in a defined format) in the content of the page and returns various status text e.g., 'true' if the found date is more recent than the passed check date, or 'false' if not, or various other error status text results
  • static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp) - a function for use in various other functions where memory is used with call back in a cURL request
  • static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream) - a function for use in various File gallery functions.
  • char* tracker_item_post(int debug, const char* domain, const char* page, const char* access_token, const char* post_data) - a function that supports the creation of a new Tiki tracker item
  • char* tracker_itemupdate(int debug, const char* domain, char* access_token, const char* trackerId, const char* itemId, const char* post_data) - a function that supports the updating of an existing Tiki tracker item
  • char* tracker_itemget(int debug, const char* domain, char* access_token, const char* trackerId, const char* itemId) - a function that supports the downloading of an existing Tiki tracker item
  • char* gallery_filedownload(int debug, const char* domain, char* access_token, const char* fileId, const char* filespath, const char* bodyfilename, const char* headerfilename) - a function to download a file from a Tiki File gallery
  • char* gallery_fileupload(int debug, const char* domain, char* access_token, const char* filepath, const char* galId, const char* filename, const char* filetitle, const char* filedesc) - a function to upload a file to a Tiki File gallery
  • char* gallery_fileupdate(int debug, const char* domain, char* access_token, const char* fileId, const char* filepath, const char* filename, const char* filetitle, const char* filedesc) - a function to update the details of an existing Tiki File gallery file

Python test code

Testing of the C code functions was carried out using a variety of SBCs operating as a local integration hub and this was initially mainly on a Raspberry Pi 5 and later it was carried out using a Raspberry Pi Compute Module 4. Some very early testing used a central Tiki24 instance, but all the main development used a central Tiki instance at https://iot.dev10.evoludata.com so that the Tiki API could be further developed. This test Tiki is regularly upgraded to the latest Tiki 'master' version that is now being released as Tiki30.

Individual Python programs that use/test each of the main Tiki API IoT functions have also been developed and published as 'templates', describing how they should be configured for the specific Tiki environment, e.g. URL, API authorisation token, etc..

They are as follows (the 260620 numbering indicates the current version i.e., YYMMDD):

  • IoT_just_check_web_content_260620.py
  • IoT_just_check_web_date_260620.py
  • IoT_just_down_file_260620.py
  • IoT_just_download_web_page_260620.py
  • IoT_just_get_tracker_item_260620.py
  • IoT_just_up_file_260620.py
  • IoT_just_update_file_260620.py
  • IoT_just_update_T_opcode_260620.py
  • IoT_just_update_tracker_item_260620.py
  • IoT_just_upload_new_tracker_item_260620.py


The images below illustrate the various Raspberry Pi SBCs used for testing.

Raspberry Pi 5 - conventional boot from a SD card

Raspberry Pi 5 with 8GB of RAM, running the Bookworm OS, fitted with the Active Cooler accessory and all housed in a custom 3D printed case.
Image Image

Raspberry Pi 5 - boot from a NMVe SSD

Raspberry Pi 5 with 8GB RAM, running the Bookwork OS and fitted with the Active Cooler accessory - but now reconfigured to use the single lane PCI Express (PCIe) connector available on the Pi 5 to fit the Pimoroni NVMe Base with a 500GB NMVe SSD, and all housed in its own custom 3D printed case.
Image Image Image

Raspberry Pi Compute Module 4 - boot from 32GB eMMC

Raspberry Pi Compute Module 4 with 2GB of RAM and 32GB of eMMC, fitted to the CM4 IO Board, and running the Bookworm 64bit OS. This assembly was housed in a Waveshare enclosure with a cooling fan and an external antenna as shown in the images below.
Image Image Image


All the current pages in this Structure:  





Show PHP error messages