RPi Locator and Display Services
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <glib.h>
#include <gio/gio.h>
#include <glib-unix.h>
#include <gio/gnetworking.h>
#include <ifaddrs.h>
Go to the source code of this file.
Data Structures | |
struct | _ipBroadcastArray |
struct | _signalData |
struct | _registryData |
struct | _controlData |
Macros | |
#define | PACKAGE_VERSION "0.9.0" |
#define | PACKAGE_NAME "cmdDC" |
#define | PACKAGE_DESCRIPTION "Send Message to Raspberry Pi's on the network." |
#define | G_OPTION_FLAG_NONE 0 |
#define | UDP_DISPLAY_COMM_PORT 48029 |
#define | UDP_BROADCAST_PORT 48028 |
#define | UDP_REGULAR_PORT 48027 |
#define | UDP_CLIENTS_PORT 48026 |
#define | MS_TEN_MINUTES 600000 |
#define | MSG_DELAY_INTERVAL 10 |
#define | SZ_TIMESTAMP_BUFF 32 |
#define | SZ_PARAMS_BUFF 64 |
#define | SZ_RMTADDR_BUFF 256 |
#define | SZ_MESSAGE_BUFF 512 |
#define | SZ_RESPONSE_BUFF 256 |
#define | SZ_CHAR_LABEL 48 |
#define | SZ_INFO_BUFF 256 |
#define | SZ_CHAR_BUFF 128 |
#define | SZ_LINE_BUFF 512 |
#define | SZ_COMM_BUFF 256 |
#define | SKN_UDP_ANY_PORT 0 |
#define | ARY_MAX_INTF 8 |
#define | PLATFORM_ERROR -1 |
Typedefs | |
typedef struct _ipBroadcastArray | IPBroadcastArray |
typedef struct _ipBroadcastArray * | PIPBroadcastArray |
typedef struct _signalData | USignalData |
typedef struct _signalData * | PUSignalData |
typedef struct _registryData | RegData |
typedef struct _registryData * | PRegData |
typedef struct _registryData ** | PPRegData |
typedef struct _controlData | ControlData |
typedef struct _controlData * | PControlData |
#define ARY_MAX_INTF 8 |
Definition at line 62 of file cmdDC.c.
Referenced by get_broadcast_ip_array(), and skn_get_broadcast_ip_array().
#define PACKAGE_DESCRIPTION "Send Message to Raspberry Pi's on the network." |
#define PACKAGE_VERSION "0.9.0" |
cmdDC.c IOT/RaspberryPi message display client gcc -v pkg-config --cflags --libs glib-2.0 gio-2.0
-O3 -Wall -o cmdDC cmdDC.c
Program Flow:
Definition at line 19 of file cmdDC.c.
Referenced by main(), skn_handle_display_command_line(), and skn_handle_locator_command_line().
#define PLATFORM_ERROR -1 |
Definition at line 63 of file cmdDC.c.
Referenced by generate_loadavg_info(), get_broadcast_ip_array(), get_default_interface_name_and_ipv4_address(), service_registry_get_via_udp_broadcast(), service_registry_provider(), skn_device_manager_init_i2c(), skn_device_manager_LCD_setup(), skn_device_manager_SerialPort(), skn_display_manager_do_work(), skn_get_broadcast_ip_array(), skn_get_default_interface_name_and_ipv4_address(), skn_signal_manager_handler_thread(), skn_signal_manager_startup(), and skn_udp_service_request().
#define SKN_UDP_ANY_PORT 0 |
Definition at line 61 of file cmdDC.c.
Referenced by main(), and udp_initialize_message_send().
#define SZ_CHAR_BUFF 128 |
Definition at line 57 of file cmdDC.c.
Referenced by get_broadcast_ip_array(), get_default_interface_name_and_ipv4_address(), main(), service_registry_get_via_udp_broadcast(), skn_device_manager_MCP23008(), skn_device_manager_MCP23017(), skn_device_manager_PCF8574(), skn_device_manager_SerialPort(), skn_get_broadcast_ip_array(), skn_get_default_interface_name_and_ipv4_address(), and skn_program_name_and_description_set().
#define SZ_COMM_BUFF 256 |
Definition at line 59 of file cmdDC.c.
Referenced by main(), and service_registry_provider().
#define SZ_INFO_BUFF 256 |
Definition at line 56 of file cmdDC.c.
Referenced by generate_cpu_temps_info(), generate_datetime_info(), generate_loadavg_info(), generate_rpi_model_info(), generate_uname_info(), get_default_interface_name(), main(), service_registry_get_via_udp_broadcast(), service_registry_provider(), skn_display_manager_add_line(), skn_display_manager_create(), skn_display_manager_do_work(), skn_display_manager_message_consumer_thread(), skn_get_default_interface_name(), skn_scroller_wrap_blanks(), skn_service_request_create(), skn_udp_service_request(), sknGetConstants(), sknGetModuleBright(), sknGetModuleTemp(), and sknGetTemp().
#define SZ_LINE_BUFF 512 |
Definition at line 58 of file cmdDC.c.
Referenced by skn_strip().
#define SZ_RMTADDR_BUFF 256 |
Definition at line 51 of file cmdDC.c.
Referenced by udp_registry_response_parser().
#define UDP_BROADCAST_PORT 48028 |
Definition at line 43 of file cmdDC.c.
Referenced by skn_udp_network_broadcast_all_interfaces().
typedef struct _controlData ControlData |
typedef struct _ipBroadcastArray IPBroadcastArray |
typedef struct _controlData * PControlData |
typedef struct _ipBroadcastArray * PIPBroadcastArray |
typedef struct _registryData ** PPRegData |
typedef struct _registryData * PRegData |
typedef struct _signalData * PUSignalData |
typedef struct _registryData RegData |
typedef struct _signalData USignalData |
|
static |
Definition at line 562 of file cmdDC.c.
References _controlData::ch_display_service_name, _registryData::ch_from, _registryData::ch_ip, _registryData::ch_name, _registryData::ch_port, _registryData::ch_timestamp, _controlData::glRegistry, _controlData::loop, _registryData::pch_message, _controlData::resolver, skn_get_timestamp(), skn_gio_condition_to_string(), and udp_registry_response_parser().
Referenced by main().
|
static |
Definition at line 526 of file cmdDC.c.
References _controlData::ch_display_service_name, _controlData::ch_message, _controlData::gErrorCount, _controlData::gsDSAddr, _controlData::gSock, and _controlData::loop.
Referenced by udp_initialize_message_send().
|
static |
Definition at line 468 of file cmdDC.c.
References _controlData::ch_request, _controlData::ch_response, _controlData::gErrorCount, _controlData::resolver, and skn_get_timestamp().
Referenced by udp_initialize_message_send().
|
static |
Definition at line 698 of file cmdDC.c.
References _controlData::ch_display_service_name, _registryData::ch_ip, _registryData::ch_name, _registryData::ch_port, _controlData::gBroadcastSocket, _controlData::glRegistry, _controlData::gMsgDelay, _controlData::gReady, _controlData::gRegistryQueries, _controlData::gsDSAddr, _controlData::paB, skn_udp_network_broadcast_all_interfaces(), udp_initialize_message_send(), and udp_registry_find_by_name().
Referenced by main().
|
static |
Definition at line 743 of file cmdDC.c.
References _signalData::loop, and _signalData::signalName.
Referenced by main().
int main | ( | int | argc, |
char ** | argv | ||
) |
Definition at line 749 of file cmdDC.c.
References cb_udp_broadcast_response_handler(), cb_udp_registry_select_handler(), cb_unix_signal_handler(), _controlData::ch_display_service_name, _controlData::ch_intfName, _controlData::ch_message, _controlData::ch_this_ip, FALSE, G_OPTION_FLAG_NONE, _controlData::gBroadcastSocket, _controlData::gCommSource, _controlData::gErrorCount, _controlData::glRegistry, _controlData::gMsgDelay, _controlData::gReady, _controlData::gRegCount, _controlData::gRegistryQueries, _controlData::gsAddr, _controlData::gsDSAddr, _controlData::gSock, _signalData::loop, _controlData::loop, MSG_DELAY_INTERVAL, _controlData::paB, _controlData::resolver, _controlData::sigHup, _controlData::sigInt, _signalData::signalName, _controlData::sigTerm, skn_get_default_interface_name_and_ipv4_address(), SKN_UDP_ANY_PORT, skn_udp_network_broadcast_all_interfaces(), and TRUE.
gint skn_get_broadcast_ip_array | ( | PIPBroadcastArray | paB | ) |
Collect IP and Broadcast Addresses for this machine
Definition at line 185 of file cmdDC.c.
References ARY_MAX_INTF, _ipBroadcastArray::broadAddrStr, _ipBroadcastArray::cbName, _ipBroadcastArray::chDefaultIntfName, _ipBroadcastArray::count, _ipBroadcastArray::defaultIndex, _ipBroadcastArray::ifNameStr, _ipBroadcastArray::ipAddrStr, _ipBroadcastArray::maskAddrStr, PLATFORM_ERROR, skn_get_default_interface_name(), and SZ_CHAR_BUFF.
Referenced by skn_get_default_interface_name_and_ipv4_address().
gint skn_get_default_interface_name | ( | char * | pchDefaultInterfaceName | ) |
Retrieves default internet interface name into param
[jscott OSX]$ route -n get 0.0.0.0 route to: default destination: default mask: default gateway: 10.21.1.254 interface: en3 flags: <UP,GATEWAY,DONE,STATIC,PRCLONING> recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire 0 0 0 0 0 0 1500 0
Definition at line 246 of file cmdDC.c.
References skn_strip(), and SZ_INFO_BUFF.
Referenced by skn_get_broadcast_ip_array().
PIPBroadcastArray skn_get_default_interface_name_and_ipv4_address | ( | char * | intf, |
char * | ipv4 | ||
) |
PIPBroadcastArray skn_get_default_interface_name_and_ipv4_address | ( | gchar * | intf, |
gchar * | ipv4 | ||
) |
Definition at line 165 of file cmdDC.c.
References _ipBroadcastArray::chDefaultIntfName, _ipBroadcastArray::defaultIndex, _ipBroadcastArray::ipAddrStr, PLATFORM_ERROR, skn_get_broadcast_ip_array(), and SZ_CHAR_BUFF.
gchar * skn_get_timestamp | ( | ) |
Definition at line 323 of file cmdDC.c.
Referenced by cb_udp_broadcast_response_handler(), and cb_udp_comm_response_handler().
gchar * skn_gio_condition_to_string | ( | GIOCondition | condition | ) |
Definition at line 330 of file cmdDC.c.
Referenced by cb_udp_broadcast_response_handler().
gchar * skn_strip | ( | gchar * | alpha | ) |
Remove Trailing and Leading Blanks
Definition at line 139 of file cmdDC.c.
Referenced by skn_get_default_interface_name().
gboolean skn_udp_network_broadcast_all_interfaces | ( | GSocket * | gSock, |
PIPBroadcastArray | paB | ||
) |
Send a registry request on the broadcast ip of all interfaces
gSock | IN GLib active/bound socket with broadcast enabled |
ch_request | IN Greetings message, anytext |
ch_intfName | OUT Default Ethernet Interface Name |
ch_ipAddress | OUT Default Ethernet IP Address |
Definition at line 297 of file cmdDC.c.
References _ipBroadcastArray::broadAddrStr, _ipBroadcastArray::count, _ipBroadcastArray::defaultIndex, _ipBroadcastArray::ifNameStr, _ipBroadcastArray::ipAddrStr, TRUE, and UDP_BROADCAST_PORT.
Referenced by cb_udp_registry_select_handler(), and main().
gboolean udp_initialize_message_send | ( | PControlData | pctrl | ) |
Definition at line 657 of file cmdDC.c.
References cb_udp_comm_request_handler(), cb_udp_comm_response_handler(), FALSE, _controlData::gCommSource, _controlData::gMsgDelay, _controlData::gsAddr, _controlData::gSock, SKN_UDP_ANY_PORT, and TRUE.
Referenced by cb_udp_registry_select_handler().
gint udp_registry_find_by_name | ( | PRegData | pr, |
gchar * | pch_name | ||
) |
Definition at line 694 of file cmdDC.c.
References _registryData::ch_name.
Referenced by cb_udp_registry_select_handler().
Parse this response message
Format: name=rpi_locator_service,ip=10.100.1.19,port=48028| name=lcd_display_service,ip=10.100.1.19,port=48029|
the vertical bar char '|' is the line separator, % and ; are also supported
Definition at line 368 of file cmdDC.c.
References _registryData::ch_ip, _registryData::ch_name, _registryData::ch_port, FALSE, SZ_RMTADDR_BUFF, and TRUE.
Referenced by cb_udp_broadcast_response_handler().