Comments (14)
By building the MNS server on PC before sending the RemoteNotificationRegister
request to MSE, I can now receive notifications.
MasObexConnect success is: True
**************************************************
MNS: Start advertising MNS service
Wait for 1 seconds
**************************************************
Sending RemoteNotificationRegister request
Sending request packet: 1
ConnectionId: 0A-90-5E-00
82-00-33-CB-0A-90-5E-00-42-00-25-78-2D-62-74-2F-4D-41-50-2D-4E-6F-74-69-66-69-63-61-74-69-6F-6E-52-65-67-69-73-74-72-61-74-69-6F-6E-00-4C-00-06-0E-01-01
Opcode: PutAlter
Req packet sent. Waiting for reply...1
ReadFromStream:: Opcode: Success
packet length: 3
Header size to read is zero.
Reply packet:
A0-00-03
ResponseCode: Success
No header returned.
Request returned success
RemoteNotificationRegister success is: True
Enter q to exit or other keys to try again...
Connection received
Stoping Advertising
ReadFromStream:: Opcode: Connect
packet length: 26
70
Opcode: Connect
ReadFromStream:: Opcode: PutAlter #SendEvent from MSE
packet length: 243
66
76
73
Opcode: PutAlter
I can't push to your fork so I push 6f83fa5 to this branch
from myphone.
Sorry for the late reply. It's been a busy week.
This is a known issue. I guess it's because the MAP demo doesn't handle the ConnectionId.
Line 192 in 9cb86e8
from myphone.
Not sure if that is the root cause. I used ConnectionId from OBEX connection call and still getting Response Code "D3". And "D3" is not a valid MAP response code based on the specification document.
Get ConnectionId here:
OBEXConnectPacket packet = new OBEXConnectPacket();
var buf = packet.ToBuffer();
....
OBEXPacket retPacket = await OBEXPacket.ReadFromStream(_reader, packet);
if (retPacket != null)
{
var bytes = retPacket.ToBuffer().ToArray();
foreach (var header in retPacket.Headers)
{
if (header.HeaderId.Equals(HeaderId.ConnectionId))
{
ConnectionHeader = new Int32ValueHeader(HeaderId.ConnectionId, ((Int32ValueHeader)header).Value);
break;
}
}
}
Set ConnectionId here:
OBEXPacket packet = new OBEXPacket(
ConnectionHeader
,new StringValueHeader(HeaderId.Type, "x-bt/MAP-NotificationRegistration")
,new AppParamHeader(new AppParameter(AppParamTagId.NotificationStatus, 1))
,new BytesHeader(HeaderId.Body, 0x30)
,new BytesHeader(HeaderId.EndOfBody, 0x30)
//,new BytesHeader(HeaderId.Target, MAS_UUID)
);
packet.Opcode = Opcode.PutAlter;
Sending MAP client Connection request to Phone MAP server:
80-00-1A-10-00-FF-FF-46-00-13-BB-58-2B-40-42-0C-11-DB-B0-DE-08-00-20-0C-9A-66
Opcode: Connect
Waiting reply packet:
Opcode: Success
Reply packet:
A0-00-32-10-00-0F-A0-46-00-13-BB-58-2B-40-42-0C-11-DB-B0-DE-08-00-20-0C-9A-66-CB-E0-65-00-1D-4A-00-13-BB-58-2B-40-42-0C-11-DB-B0-DE-08-00-20-0C-9A-66
ResponseCode: Success
Target: BB-58-2B-40-42-0C-11-DB-B0-DE-08-00-20-0C-9A-66
ConnectionId: E0-65-00-1D
Who: BB-58-2B-40-42-0C-11-DB-B0-DE-08-00-20-0C-9A-66
Sending MAP client notification registration request to Phone MAP server:
82-00-3B-CB-E0-65-00-1D-42-00-25-78-2D-62-74-2F-4D-41-50-2D-4E-6F-74-69-66-69-63-61-74-69-6F-6E-52-65-67-69-73-74-72-61-74-69-6F-6E-00-4C-00-06-0E-01-01-48-00-04-30-49-00-04-30
Opcode: PutAlter
Waiting reply packet:
Reply packet:
D3-00-03
ResponseCode: 211
Remote request failed.
from myphone.
Looks like "D3" is from OBEX specification,
No more than one Reliable OBEX Session shall exist at any time on each transport connection, which is equivalent to the L2CAP channel connection. If a CREATE SESSION command is issued while an active Reliable Session already exists, the operation shall be rejected with the Service Unavailable (0xD3) response code. If a CREATE SESSION command is issued while a suspended Reliable Session exists, the operation may be rejected with the Service Unavailable (0xD3) response code, or the suspended session may be removed and a new Reliable Session created.
from myphone.
If connection id is NOT reversed, then the response code is no longer 0xD3 but 0x90. However, no valid data is return when we continue making the Get request.
MyPhone/MyPhone.OBEX/OBEXHeader.cs
Lines 67 to 70 in ede21d4
Sending RemoteNotificationRegister request
Sending request packet: 1
02-00-46-CB-1D-00-65-E0-42-00-25-78-2D-62-74-2F-4D-41-50-2D-4E-6F-74-69-66-69-63-61-74-69-6F-6E-52-65-67-69-73-74-72-61-74-69-6F-6E-00-4C-00-06-0E-01-01-46-00-13-BB-58-2B-40-42-0C-11-DB-B0-DE-08-00-20-0C-9A-66
Opcode: Put
Req packet sent. Waiting for reply...1
ReadFromStream:: Opcode: Continue
packet length: 3
Header size to read is zero.
Reply packet:
90-00-03
ResponseCode: Continue
No header returned.
Sending request packet: 2
02-00-03
Opcode: Put
Req packet sent. Waiting for reply...2
ReadFromStream:: Opcode: Continue
packet length: 3
Header size to read is zero.
...
I created additional MAS functions to test. However currently the only one worked is OBEX Connect request. My fork
from myphone.
Why is this issue closed? It has not been resolved.
from myphone.
Why is this issue closed? It has not been resolved.
I was able to get remote notification to work by following changes in the Connection Id handling:
public override void FromBytes(byte[] bytes)
{
if (HeaderId.Equals(HeaderId.ConnectionId))
{
Value = IPAddress.NetworkToHostOrder(BitConverter.ToInt32(bytes));
}
else
{
Value = BitConverter.ToInt32(bytes);
}
}
public override byte[] ToBytes()
{
byte[] ret;
if (HeaderId.Equals(HeaderId.ConnectionId))
{
ret = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(Value));
}
else
{
ret = BitConverter.GetBytes(Value);
}
return ret;
}
my changes are available from my fork as well.
BTW, do you have suggestions for:
- how to actually receive and handle the Notification? and
- how to send message to phone?
from myphone.
1. Receive and handle the Notification
- Establish MNS service connection (SetNotificationRegistration)
- Once the MNS service connection is established, the MSE (phone) will send
SendEvent
function to MCE (PC) which contains the message handle when a new message arrives. - MCE (PC) send
GetMessage
function to MSE(Phone) to get the message content - Show the toast notification on MCE(PC) (For Windows 10/11, we can use this library, https://github.com/CommunityToolkit/WindowsCommunityToolkit/tree/main/Microsoft.Toolkit.Uwp.Notifications)
from myphone.
2. Send message to phone
Send PushMessage
function to MSE(Phone)
from myphone.
2. Send message to phone
Send
PushMessage
function to MSE(Phone)
I have been working on PushMessage for couple days and no success so far. Any working example by chance? My example is attached below.
In terms of getting the notification from the phone, I understand the high level flow. The demo code has 1 (2), 3 implemented but I don't see the GetMessage been triggered. No success so far.
PushMessage OBEX object payload with no success:
StringBuilder mssg = new StringBuilder();
mssg.AppendLine("BEGIN:BMSG");
mssg.AppendLine("VERSION: 1.0");
mssg.AppendLine("STATUS: UNREAD");
mssg.AppendLine("TYPE: SMS_GSM");
mssg.AppendLine("FOLDER:telecom/msg/outbox");
mssg.AppendLine("BEGIN: VCARD");
mssg.AppendLine("VERSION:2.1");
mssg.AppendLine("N: null");
mssg.AppendLine("TEL: 1234567891");
mssg.AppendLine("END: VCARD");
mssg.AppendLine("BEGIN:BENV");
mssg.AppendLine("BEGIN:BBODY");
mssg.AppendLine("CHARSET:UTF - 8");
mssg.AppendLine("LENGTH: 51");
mssg.AppendLine("BEGIN: MSG");
mssg.AppendLine("Joey Pigza Swallowed the Key;");
mssg.AppendLine("END: MSG");
mssg.AppendLine("END:BBODY");
mssg.AppendLine("END:BENV");
mssg.AppendLine("END:BMSG");
OBEXPacket packet = new OBEXPacket(
Opcode.PutAlter
, ConnectionHeader
, new TypeHeader("x-bt/message")
, new NameHeader("telecom/msg/outbox")
, new BodyHeader(HeaderId.Body, mssg.ToString())
);
from myphone.
I will try to implement a working demo in the next few days. I will post updates here if I make any progress.
from myphone.
I will try to implement a working demo in the next few days. I will post updates here if I make any progress.
Sounds good! I will update if I have success as well :)
from myphone.
I fixed the bmessage format and it is working with the demo code. The only thing really need the fix is the Connection Id. I have not tested receiving notification yet though.
from myphone.
Let's move the discussion here #5 since this issue is closed.
from myphone.
Related Issues (20)
- Unable to build on Windows 11 HOT 23
- Publish Releases HOT 15
- USB cable support HOT 1
- Plans for MyPhone HOT 5
- iphone support HOT 4
- Support for multiple numbers & devices HOT 3
- Use mic on phone
- Not able to run the sample on windows 10 desktop HOT 9
- Can you add a release or re-run Github Actions? HOT 1
- statue panel not showing calling number or name
- two phones connected ? HOT 1
- After I Change a blueteeth Adapter .Thrown "Object reference not set to an instance of an object" HOT 2
- Where is the .exe? HOT 3
- PhoneLineTransportDevice API no longer works on Windows 22H2 HOT 17
- Why call audio not transferred to PC when making calls with Handsfree profile? HOT 1
- TransportDevice.ConnectAsync() not working on Windows Form application.
- Incoming call handle HOT 5
- Could not open the UWP App: System.IO.FileLoadException HOT 12
- Migrating to Windows App SDK (WinUI 3) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from myphone.