{"id":23828817,"url":"https://github.com/ssoudan/sdp","last_synced_at":"2026-05-14T23:34:46.343Z","repository":{"id":9920783,"uuid":"11931782","full_name":"ssoudan/SDP","owner":"ssoudan","description":"A Service Discovery Protocol for Arduino-Xbee based sensor networks.","archived":false,"fork":false,"pushed_at":"2015-07-29T12:53:41.000Z","size":232,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-02T13:36:51.867Z","etag":null,"topics":["arduino","sensor-network","service-discovery-protocol","xbee"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"AHAAAAAAA/PokemonGo-Map","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ssoudan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-08-06T18:49:09.000Z","updated_at":"2019-03-14T16:15:04.000Z","dependencies_parsed_at":"2022-08-27T13:33:00.688Z","dependency_job_id":null,"html_url":"https://github.com/ssoudan/SDP","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssoudan%2FSDP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssoudan%2FSDP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssoudan%2FSDP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssoudan%2FSDP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ssoudan","download_url":"https://codeload.github.com/ssoudan/SDP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240118330,"owners_count":19750471,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","sensor-network","service-discovery-protocol","xbee"],"created_at":"2025-01-02T13:37:04.542Z","updated_at":"2026-05-14T23:34:41.324Z","avatar_url":"https://github.com/ssoudan.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\t   _____ ____  ____ \n\t  / ___// __ \\/ __ \\\n\t  \\__ \\/ / / / /_/ /\n\t ___/ / /_/ / ____/ \n\t/____/_____/_/      ...\n\t\tService Discovery Protocol for Embedded devices.\n\n\nSebastien Soudan \u003csebastien.soudan@gmail.com\u003e 2013\n\nGPLv3\n\nA Service Discovery Protocol for Arduino-Xbee based sensor networks.\n\n===============\nPrinciple\n===\n\n* One board register an action it can offer on a service\n* Another board want this action to be executed but have \n  no clue on who is offering this service\n* This second guy, send a broadcast message to find the \n  service: (FS message)\n* The first guy, or maybe another one, or both respond \n  with a 'find service' response message (FSR) giving \n  their addresses.\n* Next time first want to execute the action, he can \n  just send directly a 'do action' message (DA) in \n  unicast with the parameter payload and with get a \n  response (or not) from the guy targeted by the message.\n  Upon the reception of this 'do action' response message\n  (DAR), the callback he has provided with the doAction, \n  will be executed on the result of the execution of the\n  remote method that has been packed in the DAR message\n  together with the status in case this one is DONE.\n\nNote that there are some 'corner' cases that are not yet supported by this lib:\n* the address of the first guy that replied to the FS will not be overriden by the \n  one of the second guy (provider as well) which will get a seat in the \n  Remote Service Directory but never be called because the search method sucks.\n* In case the first guy disappear, there is no timeout mechanism to remove the entry.\n  Though in case of an error during the execution of an action (NOT_DONE status), \n  the entry is removed.\n\nNote that you can also use it with local serial port of the machine. This works great \nto query the service from a Raspberry Pi using Sparkfun XBee explorer for example as \nservers/collector.cpp does for example.\n\n\n===============\nTo Do: \n===\n- [ ] refactor the *Service into proper OOP code\n- [ ] extract XBee from the stuff\n- [ ] add timeout mechanism\n- [ ] refine service/action model (single callback for an entire service?)\n- [X] add location concept to the service\n- [ ] improve the way the xmit status is checked\n- [X] use it\n\n===============\nGetting started\n===\n\n* Get Arduino-Makefile [https://github.com/sudar/Arduino-Makefile] from Sudar.\n\nMy tree looks like something like:\n\n\t.../Arduino-Makefile/...\n\t\n\t.../libraries/AdafruitLCD\n\t.../libraries/AdafruitMPL115A2\n\t.../libraries/AdafruitRGBLCDShieldLibraryMaster\n\t.../libraries/RTClib\n\t.../libraries/SDP \t\t\t\t\t\t\u003c- the lib we are talking about\n\t.../libraries/SDP/examples/Zero_v0/ \t\u003c- the example thereafter\n\t.../libraries/SDP/examples/Zero_v0/Makefile \t\u003c- [ the makefile next \n \t.../libraries/TFTLCD\t\t\t\t\t\t\t   [ bullet point is about\n\t.../libraries/TKLCD\n\t.../libraries/TinkerKit\n\t.../libraries/USB_Host_Shield_20\n\t.../libraries/XBee\t\t\t\t\t\t\u003c- one the lib dependencies\n\t\n\t\n\t.../Uno_v0/Uno_v0.ino\n\n* Create your own project Makefile similar to this one:\n\n```\n\t#\n\t# Service Discovery Protocol - Makefile\n\t# @author: Sebastien Soudan \u003csebastien.soudan@gmail.com\u003e\n\t#\n\tARDMK_DIR=../../../../Arduino-Makefile/\n\tARDUINO_DIR=/Applications/Arduino-1.0.5.app/Contents/Resources/Java\n\n\t# if you want some debug info (beware of the total size in RAM):\n\t#CPPFLAGS=-DDEBUG \n\n\tBOARD_TAG = uno \n\n\tMONITOR_PORT = /dev/cu.usb*\n\n\tARDUINO_LIBS = AdafruitRGBLCDShieldLibraryMaster \\\n\t\t\t\t   AdafruitMPL115A2 \\\n\t\t\t\t   RTClib \\\n\t\t\t\t   SDP \\\n\t\t\t\t   XBee \\\n\t\t\t\t   Wire \\\n\t\t\t\t   Wire/utility\n\n\tinclude $(ARDMK_DIR)/arduino-mk/Arduino.mk\n```\n\n* Create your own code but here is an example:\n```\n\t#include \u003cSDP.h\u003e // Service Discovery lib\n\t// Xbee\n\tXBee xbee = XBee();\n\n\t// SDP\n\tSDP sdp = SDP(\u0026xbee);\n\n\t// Remember to put the address of your XBee board here\n\tXBeeAddress64 local64 = XBeeAddress64(0xbadc0de, 0xdeadbeef);\n\n\t/**\n\t    Service function to return epoch date on Jan, 1st 1970\n\t */\n\tsize_t getDate(uint8_t *in, size_t inLength, uint8_t *out, size_t outLimit) {\n\t \n\t    Serial.println(\"getDate\");\n\n\t    if (outLimit \u003e= 4) {\n\n\t      uint32_t epoc = 0; \n\n\t      convertUint32toArray(epoc, out);\n\t      return 4;\n\t    }\n\n\t    return 0;\n\t}\n\n\tvoid setup() {\n\n\t  // Debugging output\n\t  Serial.begin(9600);\n\n\t  Serial.println(\"setup!\");\n\n\t  // Init xbee\n\t  xbee.begin(Serial);\n\t  \n\t  sdp.setLocal64(local64);\n\t  Serial.println(\"SDP init\");\n\n\t  // Service Discovery registration \n\t  RegistrationStatus res = sdp.registerService(ServiceDiscovery::SDP_RTC, \n\t  \t\t\t\t\t\t\t\t\t\t\t ServiceDiscovery::GET_VALUE, \n\t  \t\t\t\t\t\t\t\t\t\t\t \u0026getDate);\n\t  if (!res) { /* Registration has failed */ }\n\n\t}\n\n\t/**\n\t \tGet packet read and processed.\n\t\treadPackets() returns a state giving some info about\n\t\twhat has been done. But I removed it to save some place.\t\n\t */\n\tvoid processMessage() {\n\t   /* SDPState state = */ sdp.readPackets();\n\t}\n\n\t/**\n\t\tAction callback.\n\t\tExecuted when a reponse to a DO ACTION message has been\n\t\tsent, and the action has been successfully executed. \n\t */\n\tvoid actionCallback(uint8_t *data, size_t size) {\t\n\t\t// do something with the data\n\t}\n\n\tvoid loop() {\n\t  processMessage();\n\n\t  ActionStatus as = sdp.doAction(ServiceDiscovery::TEMPERATURE, \n\t\t\t\t\t\t\t\t\t ServiceDiscovery::GET_VALUE, \n\t\t\t\t\t\t\t\t\t 0, \n\t\t\t\t\t\t\t\t\t NULL, \n\t\t\t\t\t\t\t\t\t \u0026actionCallback);\n\t  // flash some led according to the status in 'as'?\n\n\t  // do a lot of other stuff here.\n\t  delay(300);\n\t}\n```\n\n\t                    \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssoudan%2Fsdp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fssoudan%2Fsdp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssoudan%2Fsdp/lists"}