{"id":25830890,"url":"https://github.com/lab5e/spangw","last_synced_at":"2026-06-23T16:31:50.049Z","repository":{"id":65695804,"uuid":"597015321","full_name":"lab5e/spangw","owner":"lab5e","description":"Gateway library for Span","archived":false,"fork":false,"pushed_at":"2024-07-04T14:19:29.000Z","size":48,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-19T12:25:03.111Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lab5e.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-02-03T12:45:33.000Z","updated_at":"2024-07-04T14:19:31.000Z","dependencies_parsed_at":"2024-06-20T11:09:51.168Z","dependency_job_id":"8df50e1d-8593-45b3-b59a-f1fa99ae0268","html_url":"https://github.com/lab5e/spangw","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/lab5e/spangw","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lab5e%2Fspangw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lab5e%2Fspangw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lab5e%2Fspangw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lab5e%2Fspangw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lab5e","download_url":"https://codeload.github.com/lab5e/spangw/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lab5e%2Fspangw/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34698687,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-23T02:00:07.161Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-02-28T19:34:34.481Z","updated_at":"2026-06-23T16:31:50.015Z","avatar_url":"https://github.com/lab5e.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Span Gateway library\n\nThis is a library that implements the boilerplate gateway code for Span. Implement the `CommandHandler`\ninterface to add gateway functionality.\n\nThere's a sample implementation that will emulate a gateway in the `emulator` package.\n\nThe gateway can be launched with a few lines of code: \n\n```golang\nfunc main() {\n\tvar config gw.Parameters    \n    // ... set parameters here\n\n    var myGatewayHandler gw.CommandHandler\n    // ..create handler here\n\n\tgwHandler, err := gw.Create(config, myGatewayHandler)\n\tif err != nil {\n\t\tlog.Printf(\"Error creating gateway: %v\", err)\n\t\tos.Exit(2)\n\t}\n\n\tdefer gwHandler.Stop()\n\tif err := gwHandler.Run(); err != nil {\n\t\tlog.Printf(\"Could not run the gateway process: %v\", err)\n\t\tos.Exit(2)\n\t}\n}\n```\n\n## Building\n\nInstall dependencies with\n\n`make tools``\n\nBuild the sample service with\n\n`make``\n\n## Test the gateway emulator\n\nThis project includes a simple gateway implementation (see the `emulator` package) that \ngenerates upstream messages for a random device every 30 seconds. \n\nCreate a new collection for your device(s) and gateway via the [Span CLI](https://github.com/lab5e/spancli):\n\n```shell\nspan col add --tag name:\"Gateway demo collection\"\n```\n\nAdd a new gateway on the collection:\n\n```shell\nspan gw add --name \"Emulated gateway\" --collection-id={collection id from above}\n```\n\nAdd a device on the collection and configure it to use the gateway. The configuration properties \ndepends on your gateway's needs:\n\n```shell\nspan dev add --collection-id={collection ID} --gateway-id={gateway ID} --config device:no1 --config foo:bar --config bar:baz\n```\n\nFinally, create a certificate for your gateway:\n\n```shell\nspan cert create --gateway-id=17mjfma79c872g\n```\n\nYou can now observe the activity events to make sure the gateway connects to Span:\n\n```shell\nspan activitiy watch --collection-id={collection ID}\n```\n\nYou can monitor the upstream messages with\n\n```shell\nspan inbox watch --collection-id={collection ID}\n```\n\nLaunch the gateway emulator with\n\n```shell\nbin/gwemu  --cert-file=cert.crt --key-file=key.pem --state-file=state.json\n```\n\nIf you inspect the device with `span device get --device-id={device ID} --collection-id={collection ID}` you should see \nan updated device config (the fCntDn and fCntUp fields):\n\n```shell\n Device {device ID}\n Field                                        Value\n lastGatewayId                                {device ID}\n lastTransport                                gateway\n metadata.gateway.gatewayId                   {gateway ID}\n metadata.gateway.lastUpdate                  1715070179623\n collectionId                                 {collection ID}\n config.gateway.17mjfma79c872g.gatewayId      {gateway ID}\n config.gateway.17mjfma79c872g.params.foo     bar\n config.gateway.17mjfma79c872g.params.bar     baz\n config.gateway.17mjfma79c872g.params.device  no1\n config.gateway.17mjfma79c872g.params.fCntDn  9\n config.gateway.17mjfma79c872g.params.fCntUp  99\n firmware.manufacturer\n firmware.modelNumber\n firmware.serialNumber\n firmware.state                               Current\n firmware.stateMessage\n firmware.targetFirmwareId                    0\n firmware.currentFirmwareId                   0\n firmware.firmwareVersion\n tags.name                                    The demo device\n deviceId                                     {device ID}\n lastPayload                                  bXNnIDM=\n lastReceived                                 1715070269492894739\n Config {gateway ID}                          bar:baz,device:no1,fCntDn:9,fCntUp:99,foo:bar\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flab5e%2Fspangw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flab5e%2Fspangw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flab5e%2Fspangw/lists"}