{"id":20626595,"url":"https://github.com/node-m2m/m2m-bridge-gateway","last_synced_at":"2026-03-10T13:05:56.143Z","repository":{"id":158677499,"uuid":"615657117","full_name":"node-m2m/m2m-bridge-gateway","owner":"node-m2m","description":"Connect two separate edge networks using an m2m-bridge-gateway ","archived":false,"fork":false,"pushed_at":"2025-02-27T13:58:29.000Z","size":124,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-15T04:35:22.850Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/node-m2m.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}},"created_at":"2023-03-18T09:44:36.000Z","updated_at":"2025-02-27T13:58:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"85cb1d09-cf75-471c-8236-590437ce1cf2","html_url":"https://github.com/node-m2m/m2m-bridge-gateway","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/node-m2m/m2m-bridge-gateway","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-m2m%2Fm2m-bridge-gateway","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-m2m%2Fm2m-bridge-gateway/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-m2m%2Fm2m-bridge-gateway/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-m2m%2Fm2m-bridge-gateway/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/node-m2m","download_url":"https://codeload.github.com/node-m2m/m2m-bridge-gateway/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-m2m%2Fm2m-bridge-gateway/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30334412,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T12:41:07.687Z","status":"ssl_error","status_checked_at":"2026-03-10T12:41:06.728Z","response_time":106,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2024-11-16T13:14:08.135Z","updated_at":"2026-03-10T13:05:56.118Z","avatar_url":"https://github.com/node-m2m.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"\n## M2M Bridge Gateway\n![](assets/m2m-gateway.png)\n\nIn this example, an edge client from New York city will try to access an edge server from Tokyo city.\n\nThe communication path will start from an edge client connecting through an m2m client bridge gateway located in New York city. It will then communicate through an m2m server bridge gateway located in Tokyo traversing the public internet. Then finally connecting to an edge server and accessing its available resources.  \n\nAll communications traffic along the path are fully encrypted using TLS and a combination of standard public and private encryption methods.  \n\n\n\n#### 1. Create a project directory for each endpoint and install *m2m*.\n#### 2. Copy the code correspondingly from each endpoint and save it as app.js file.\n#### 3. Start each application using the saved app.js file one by one from each endpoint.\n```js\n$ node app.js\n```\n### Edge Client\n```js\nconst m2m = require('m2m')\n\nlet edge = new m2m.Edge({name:'edge client'})\n\nasync function main (){\n\n  await m2m.connect()\n    \n  /***************\n \n     Edge client\n  \n   ***************/\n  let edgeClient = new edge.client(8140) // port 8140 using localhost ip\n  \n  edgeClient.on('ready', (result) =\u003e {\n    console.log('edge server 8140 ready', result) // should be true if up and false if down\n  })  \n  \n  edgeClient.on('error', (error) =\u003e {\n    console.log('edge client error', error)\n  })\n  \n  let wd = await edgeClient.write('edge-data-source-1', 'sensor-1') \n  console.log('write: sensor-1', wd)\n\n  let rd = await edgeClient.read('edge-data-source-1') \n  console.log('read:', rd)\n\n  edgeClient.subscribe('edge-publish-data-1', (data) =\u003e {\n    console.log('subscribe:', data)\n    if(data.value \u003c 30){\n      edgeClient.write('edge-data-source-1', 'sensor-2')\n    }\n    else if(data.value \u003e 105){\n      edgeClient.write('edge-data-source-1', 'sensor-1')\n    } \n  })\n}\n\nmain()\n```\n### M2M Client Bridge\n```js\nconst m2m = require('m2m')\n  \nlet client = new m2m.Client({name:'m2m client bridge'})\nlet edge = new m2m.Edge({name:'edge server'})\n\nlet currentValue = ''\n\nasync function main (){\n\n  await m2m.connect()\n\n  /***************\n \n     M2M Client\n  \n   ***************/\n  let m2mClient = new client.access(300) // m2m virtual port 300\n  \n  m2mClient.subscribe('m2m-bridge-2', (data) =\u003e {\n    currentValue = data\n  })  \n\n  /****************\n \n     Edge Server\n  \n   ****************/\n  const edgeServer = edge.createServer(8140) // port 8140 using localhost ip\n\n  edgeServer.dataSource('edge-data-source-1', async (tcp) =\u003e {\n    let result = ''\n\n    // write \n    if(tcp.payload){\n      result = await m2mClient.write('m2m-bridge-1', tcp.payload )\n    }\n    // read\n    else{\n      result = await m2mClient.read('m2m-bridge-1')\n    }\n    tcp.send(result)   \n  })\n  \n  edgeServer.publish('edge-publish-data-1', async (tcp) =\u003e {\n    tcp.send(currentValue)  \n  })  \n}\n\nmain()\n```\n### M2M Server Bridge\n```js\nconst m2m = require('m2m')  \n\nlet m2mServer = new m2m.Server(300) // m2m virtual port 300\n\nlet edge = new m2m.Edge({name:'edge client'})\n\nasync function main (){\n\n  await m2m.connect()\n  \n  /***************\n \n    Edge client\n  \n   ***************/\n  let edgeClient = new edge.client(8150) // port 8150 using localhost ip\n  \n  edgeClient.on('ready', (result) =\u003e {\n    console.log('edge server 8150 ready', result) // should be true if up and false if down\n  })\n  \n  edgeClient.on('error', (error) =\u003e {\n    console.log('edge client error', error)\n  })    \n  \n  /***************\n \n     M2M Server\n  \n   ***************/\n  m2mServer.dataSource('m2m-bridge-1', async (ws) =\u003e {\n    let result = ''\n\n    // write\n    if(ws.payload){\n      result = await edgeClient.write('edge-data-source-1', ws.payload)\n    }\n    // read\n    else {\n      result = await edgeClient.read('edge-data-source-1')\n    }\n    ws.send(result)\n  })\n  \n  m2mServer.publish('m2m-bridge-2', async (ws) =\u003e {\n    let result = await edgeClient.read('edge-data-source-1')\n    ws.send(result)\n  })\n}\n\nmain()\n```\n### Edge Server\n```js\nconst m2m = require('m2m')\n\nlet edge = new m2m.Edge({name:'edge server'})\n\nlet currentSensor = 'sensor-1'\n\nfunction sensor1(){\n  return 25 + Math.floor(Math.random() * 10)\n}\n\nfunction sensor2(){\n  return 100 + Math.floor(Math.random() * 10)\n}\n\nasync function main (){\n\n  await m2m.connect()\n  \n  /****************\n \n     Edge Server\n  \n   ****************/\n  const edgeServer = edge.createServer(8150) // port 8150 using localhost ip\n  \n  edgeServer.dataSource('edge-data-source-1', (tcp) =\u003e {\n\n    // write\n    if(tcp.payload){\n      currentSensor = tcp.payload\n      tcp.send({topic:tcp.topic, currentSensor:currentSensor})       \n    }\n    // read\n    else{\n      if(currentSensor === 'sensor-1'){\n        tcp.send({topic:tcp.topic, sensor:currentSensor, value:sensor1()}) \n      }\n      else if(currentSensor === 'sensor-2'){\n        tcp.send({topic:tcp.topic, sensor:currentSensor, value:sensor2()}) \n      }\n      else{\n        tcp.send({topic:tcp.topic, result:'invalid sensor'}) \n      }\n    }\n  })\n}\n\nmain()\n```\nOn the **edge client** output result, you should see a similar result as shown below.\n```js\nedge server 8140 ready true\nwrite: sensor-1 { topic: 'edge-data-source-1', currentSensor: 'sensor-1' }\nread: { topic: 'edge-data-source-1', sensor: 'sensor-1', value: 30 }\nsubscribe: { topic: 'edge-data-source-1', sensor: 'sensor-1', value: 27 }\nsubscribe: { topic: 'edge-data-source-1', sensor: 'sensor-1', value: 29 }\nsubscribe: { topic: 'edge-data-source-1', sensor: 'sensor-2', value: 106 }\n...\n\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-m2m%2Fm2m-bridge-gateway","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnode-m2m%2Fm2m-bridge-gateway","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-m2m%2Fm2m-bridge-gateway/lists"}